Radio button onclick event to call an handler
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Irene Bontà <irenebo... @gmail.com>
Date: Wed, 29 Aug 2012 09:22:48 -0700 (PDT)
Local: Wed, Aug 29 2012 12:22 pm
Subject: Radio button onclick event to call an handler
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>* * {{ escape(user.name) }}* * <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....
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Matthew Ferguson <mbf... @gmail.com>
Date: Wed, 29 Aug 2012 09:54:58 -0700
Local: Wed, Aug 29 2012 12:54 pm
Subject: Re: [tornado] Radio button onclick event to call an handler
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)
https://gist.github.com/515f34138d304706f93a
On Aug 29, 2012, at 9:22 AM, Irene Bontà <irenebo... @gmail.com> wrote:
> 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>
> {{ escape(user.name) }}
> <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....
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Irene Bontà <irenebo... @gmail.com>
Date: Thu, 30 Aug 2012 03:58:23 -0700 (PDT)
Local: Thurs, Aug 30 2012 6:58 am
Subject: Re: [tornado] Radio button onclick event to call an handler
Thank you for your example! It's been very useful...
But now I've tried with this solution:
{% for user in users %}
<form name="form_user_{{ user.id }}" method="post" action="/networks/{{ net.id }}/rights">
<tr>
<td>
<div>
{{ escape(user.name) }}
<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.forms['form_user_{{ user.id }}'].submit();">
<input type="radio" name="optionsRadios" id="optionsRadios2" value="1">
Read
</label>
<label class="radio inline" onclick="document.forms['form_user_{{ user.id }}'].submit();">
<input type="radio" name="optionsRadios" id="optionsRadios2" value="4">
Read + Commands
</label>
{{ xsrf_form_html() }}
</td>
</tr>
</form>
{% end %}
This solution seems work at the click, but now I have an error from Tornado:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/tornado/web.py", line 988, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/tornado/web.py", line 1739, in wrapper
return method(self, *args, **kwargs)
File "./wsn.py", line 455, in post
perm = self.get_argument("perm")
File "/usr/lib/python2.6/site-packages/tornado/web.py", line 298, in get_argument
raise HTTPError(400, "Missing argument %s" % name)
HTTPError: HTTP 400: Bad Request (Missing argument perm)
The handler is:
class NetworkRightsHandler(BaseHandler):
@tornado.web.authenticated
def post(self, netid):
usrid = self.get_argument("id")
perm = self.get_argument("perm")
ecc ecc..........
Why is not passed to the handler??? Thank you very much!
Il giorno mercoledì 29 agosto 2012 18:55:04 UTC+2, Matt F ha scritto:
> 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)
> https://gist.github.com/515f34138d304706f93a
> On Aug 29, 2012, at 9:22 AM, Irene Bontà <irene... @gmail.com <javascript:>> > wrote:
> 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>*
> * {{ escape(user.name) }}*
> * <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....
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Peter Bengtsson <pete... @gmail.com>
Date: Wed, 5 Sep 2012 11:16:40 -0700 (PDT)
Local: Wed, Sep 5 2012 2:16 pm
Subject: Re: [tornado] Radio button onclick event to call an handler
Because 'perm' is not included when the form is submitted.
On Thursday, August 30, 2012 6:58:23 AM UTC-4, Irene Bontà wrote:
> Thank you for your example! It's been very useful...
> But now I've tried with this solution:
> {% for user in users %}
> <form name="form_user_{{ user.id }}" method="post" > action="/networks/{{ net.id }}/rights">
> <tr>
> <td>
> <div>
> {{ escape(user.name) }}
> <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.forms['form_user_{{ user.id }}'].submit();">
> <input type="radio" name="optionsRadios" > id="optionsRadios2" value="1">
> Read
> </label>
> <label class="radio inline" > onclick="document.forms['form_user_{{ user.id }}'].submit();">
> <input type="radio" name="optionsRadios" > id="optionsRadios2" value="4">
> Read + Commands
> </label>
> {{ xsrf_form_html() }}
> </td>
> </tr>
> </form>
> {% end %}
> This solution seems work at the click, but now I have an error from > Tornado:
> Traceback (most recent call last):
> File "/usr/lib/python2.6/site-packages/tornado/web.py", line 988, in _execute
> getattr(self, self.request.method.lower())(*args, **kwargs)
> File "/usr/lib/python2.6/site-packages/tornado/web.py", line 1739, in wrapper
> return method(self, *args, **kwargs)
> File "./wsn.py", line 455, in post
> perm = self.get_argument("perm")
> File "/usr/lib/python2.6/site-packages/tornado/web.py", line 298, in get_argument
> raise HTTPError(400, "Missing argument %s" % name)
> HTTPError: HTTP 400: Bad Request (Missing argument perm)
> The handler is:
> class NetworkRightsHandler(BaseHandler):
> @tornado.web.authenticated
> def post(self, netid):
> usrid = self.get_argument("id")
> perm = self.get_argument("perm")
> ecc ecc..........
> Why is not passed to the handler??? Thank you very much!
> Il giorno mercoledì 29 agosto 2012 18:55:04 UTC+2, Matt F ha scritto:
>> 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)
>> https://gist.github.com/515f34138d304706f93a
>> On Aug 29, 2012, at 9:22 AM, Irene Bontà <irene... @gmail.com> wrote:
>> 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>*
>> * {{ escape(user.name) }}*
>> * <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....
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Sharkbait <irenebo... @gmail.com>
Date: Thu, 6 Sep 2012 01:17:27 +0200
Local: Wed, Sep 5 2012 7:17 pm
Subject: Re: [tornado] Radio button onclick event to call an handler
Yes ;) i solved! Thank you!
2012/9/5 Peter Bengtsson <pete... @gmail.com>
> Because 'perm' is not included when the form is submitted.
> On Thursday, August 30, 2012 6:58:23 AM UTC-4, Irene Bontà wrote:
>> Thank you for your example! It's been very useful...
>> But now I've tried with this solution:
>> {% for user in users %}
>> <form name="form_user_{{ user.id }}" method="post"
>> action="/networks/{{ net.id }}/rights">
>> <tr>
>> <td>
>> <div>
>> {{ escape(user.name) }}
>> <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.forms['form_**user_{{ user.id }}'].submit();">
>> <input type="radio" name="optionsRadios"
>> id="optionsRadios2" value="1">
>> Read
>> </label>
>> <label class="radio inline"
>> onclick="document.forms['form_**user_{{ user.id }}'].submit();">
>> <input type="radio" name="optionsRadios"
>> id="optionsRadios2" value="4">
>> Read + Commands
>> </label>
>> {{ xsrf_form_html() }}
>> </td>
>> </tr>
>> </form>
>> {% end %}
>> This solution seems work at the click, but now I have an error from
>> Tornado:
>> Traceback (most recent call last):
>> File "/usr/lib/python2.6/site-**packages/tornado/web.py", line 988, in _execute
>> getattr(self, self.request.method.lower())(***args, **kwargs)
>> File "/usr/lib/python2.6/site-**packages/tornado/web.py", line 1739, in wrapper
>> return method(self, *args, **kwargs)
>> File "./wsn.py", line 455, in post
>> perm = self.get_argument("perm")
>> File "/usr/lib/python2.6/site-**packages/tornado/web.py", line 298, in get_argument
>> raise HTTPError(400, "Missing argument %s" % name)
>> HTTPError: HTTP 400: Bad Request (Missing argument perm)
>> The handler is:
>> class NetworkRightsHandler(**BaseHandler):
>> @tornado.web.authenticated
>> def post(self, netid):
>> usrid = self.get_argument("id")
>> perm = self.get_argument("perm")
>> ecc ecc..........
>> Why is not passed to the handler??? Thank you very much!
>> Il giorno mercoledì 29 agosto 2012 18:55:04 UTC+2, Matt F ha scritto:
>>> 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)
>>> https://gist.github.com/**515f34138d304706f93a <https://gist.github.com/515f34138d304706f93a >
>>> On Aug 29, 2012, at 9:22 AM, Irene Bontà <irene... @gmail.com> wrote:
>>> 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>*
>>> * {{ escape(user.name) }}*
>>> * <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....
--
Irene Bontà
https://launchpad.net/~irenebonta
You must
Sign in before you can post messages.
You do not have the permission required to post.