Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

Thanks

like image 840
Baltimark Avatar asked Dec 02 '08 01:12

Baltimark


2 Answers

You're probably thinking of action= for the form element. onClick would just fire a javascript function.

like image 74
jamtoday Avatar answered Sep 22 '22 08:09

jamtoday


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>
</form>

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>
</form>

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.

like image 28
Benry Avatar answered Sep 23 '22 08:09

Benry