i am trying to create a javascript function which is called by the onClick property and has a parameter that I can set with PHP. I can get everything to work, mostly. The test code below function correctly--$item is set by php and is used in the javascript function submitSplit() to replace the variable test_var. When the textbox is clicked the writeln(item) line is called and 1235 is written on the screen.
The problem is, what I really want to do is use this set up to have the function submitSplit do this:
document.test_var.submit();
I want it to submit a form with a name that is set by the parameter of the function. This doesn't seem to work. Why not? Is this a simple javascript error?
<html>
<body>
<?
$item="1235";
?>
</form>
<form name='1235' action="order.php" method="get">
<input type="text" name="p1" value="<? echo $item; ?>" onClick="submitSplit(<? echo "$item"; ?>)">
<input type="button" value="go" >
</form>
<script>
function submitSplit(test_var)
{
document.writeln(test_var);
}
</script>
</body>
</html>