Html – using “onclick” with radio button in appengine


Here's a code snippet. . .

<form name="FinalAccept" method="get"><br>

<input type="radio" name="YesNo" value="Yes" onclick="/accept"> Yes<br>

<input type="radio" name="YesNo" value="No" onclick="/accept"> No<br>

Clearly, what I'm trying to do is call the routine linked to /accept when the user clicks on the radio button.

I know the routine is working because I call the same routine from another place in the program.

I'm trying to run it locally using google appserver. Is there something I'm missing?


Best Solution

If you want to submit the entire form when the user clicks on a radio button, then try this:

<form name="FinalAccept" method="get" action="accept"><br>
<input type="radio" name="YesNo" value="Yes" onclick="this.form.submit();"> Yes<br>
<input type="radio" name="YesNo" value="No" onclick="this.form.submit();"> No<br>

Plus, if you want to make your UI a little more user friendly, change it to this:

<form name="FinalAccept" method="get" action="accept"><br>
<input id="rYes" type="radio" name="YesNo" value="Yes" onclick="this.form.submit();">
<label for="rYes">Yes</label><br>
<input id="rNo" type="radio" name="YesNo" value="No" onclick="this.form.submit();">
<label for="rNo">No</label><br>

This will make the text "Yes" and "No" as clickable labels for their radio buttons. The user can click the label to select the radio button.