-->

Checking all elements with one click with Tornado

2019-08-17 04:02发布

问题:

I have this part of code in my html page:

{% if users %}
        {% for user in users %}

        <form name="form_user_{{ user.id }}" method="post" action="/networks/{{ net.id }}/sensors/{{ sens.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="perms" id="perms_{{user.id}}_0" value="0">
                None
              </label>
              <label class="radio inline" onclick="document.forms['form_user_{{ user.id }}'].submit();">
                <input type="radio" name="perms" id="perms_{{user.id}}_1" value="1">
                Read
              </label>
              <label class="radio inline" onclick="document.forms['form_user_{{ user.id }}'].submit();">
                <input type="radio" name="perms" id="perms_{{user.id}}_4" value="4">
                Read + Commands
              </label>

              {{ xsrf_form_html() }}
            </td>

          </tr>
        </form>
        {% end %}
        {% end %}

where I have a list of users from Tornado and I can set them a permission on a sensor. I would create on the top of this list a check element for every permission to assign too fast the same permission to the users.

For example if we click on a check element for the permission with value 4, I would that for every user in the users list the permission is set to 4. Something like click on every check one at time.

I'm sorry for my english. How can I do this?