Forum Moderators: coopster
I don't know exactly if this is the right forum. In my form, I would like to have my submit buttons to be clickeable just if one of my radio buttons was selected. How can I do that?
here's a simple form I'm using (I use PHP).
<HTML>
<HEAD>
<TITLE>My Form</TITLE>
</HEAD>
<BODY >
<H1 ALIGN="CENTER"> Here's my form</H1>
<?
echo "<form method=\"post\" action=\"aver.php\">".
"<table>";
for ($i=0; $i < 2; $i++)
{
echo "<tr>".
"<td>Option".$i."</td>".
"<td><input type=\"radio\" name=\"layout\" value=\"".$i."\"></td>".
"</tr>";
}
echo "</table>";
echo "<BR><input type=\"submit\" name=\"choice\" value=\"Accept\"> ";
echo "<input type=\"submit\" name=\"choice\" value=\"Help\">";
echo "</form>";
?>
<BR>Bye...
</BODY>
</HTML>
I actually use js for things like that. I switch the submit button to a regular button and then when it is clicked do some error checking.
In this case when the user clicks the button check to see if the radio is selected and if not give thm an error saying they must select one.
If you wanted to do it with php you would have to have the form submitted and then in your processing script check to see if there is a value for the radio. If not, redisplay the form with an error at the top saying they must select one of the options.