This isn't Tornado related, this is JavaScript related. However, you caught me on a good day, so I'll bite.
Inline JavaScript is bad! Bad bad bad bad bad. Glancing over your code quickly, assuming it works at all, you only have the onclick event firing on the labels, not the radio buttons themselves.
Here's what should happen:
<label> should have the "for" attribute, which is the ID of the input that should be selected when clicking on the label
You should use jQuery to attach JavaScript to your radio buttons. I put together an example for you (this is not the absolute best way to go about this)
Hi all!
I have a three choice form. I want call an handler when someone click on a radio button.
I have this html form:
<form name="form_user_{{ user.id }}" method="post" action="/networks/{{ net.id }}/rights"> <tr>
<td>
<div>
<input type='hidden' name="id" value='{{ user.id }}'> </div>
</td>
<td>
<label class="radio inline" onclick="document.forms['form_user_{{ user.id }}'].submit();"> <input type="radio" name="optionsRadios" id="optionsRadios1" value="0">
None
</label>
<label class="radio inline" onClick="document.form_user_{{ user.id }}.submit()"> <input type="radio" name="optionsRadios" id="optionsRadios2" value="1">
Read
</label>
<label class="radio inline" onClick="document.form_user_{{ user.id }}.submit()"> <input type="radio" name="optionsRadios" id="optionsRadios2" value="4">
Read + Commands
</label>
{{ xsrf_form_html() }}
</td>
</tr>
</form>
And i want call the handler (r"/networks/([0-9]+)/rights", NetworkRightsHandler) which is this:
class NetworkRightsHandler(BaseHandler):
@tornado.web.authenticated
def post(self, netid):
usrid = self.get_argument("id")
perm = self.get_argument("perm")
ecc ecc.....
My solution doesn't work. What I've to do? Thank you very much, but i'm going crazy....