I’m trying to make a form work with both JavaScript onclick submit and also textbox. The PHP is only to show the results.
– Either the <form> line is put above the form inputs, and the textbox works (and the radio button clicks and submits) but the radiobutton’s value for formVar doesn’t post.
– Or the <form> line is put below all the form inputs except above the hidden inputs, and the radiobutton clicks and submits, the radiobutton’s value for formVar posts successfully, but the textbox doesn’t work at all.
How can I get both the radiobutton onclick values to post when clicked, and the textbox to work together? Thanks. Alex
Here’s the code:
<? echo “answertxt: “.$_POST[‘answertxt’].” formVar: “.$
<form action=”test.php” method=”post” name=”myform” id=”myform”><!– if this <form> line goes here, then the textbox submits but the radio buttons’ onclick doesn’t submit the formVar value. if this <form> line goes below all the inputs, then the textbox doesn’t submit but the radio buttons onclick do submit the formVar value. –>
<input type=”radio” name=”formVar” value=”1″ onclick=”document.myform.formVar.value=’1′; document.myform.submit();”>
<input type=”text” name=”answertxt” value=”<? echo $_POST[‘answertxt’]; ?>”>
<input type=”radio” name=”formVar” value=”2″ onclick=”document.myform.formVar.value=’2′; document.myform.submit();”>
<input type=”hidden” name=”formVar” value=””>
</form>