Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Radio button onclick event to call an handler
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Irene Bontà  
View profile  
 More options Aug 29 2012, 12:22 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matthew Ferguson  
View profile  
 More options Aug 29 2012, 12:55 pm
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Irene Bontà  
View profile  
 More options Aug 30 2012, 6:58 am
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Bengtsson  
View profile  
 More options Sep 5 2012, 2:16 pm
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sharkbait  
View profile  
 More options Sep 5 2012, 7:17 pm
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>

--
Irene Bontà
https://launchpad.net/~irenebonta

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »