get the value of selected form input then pass it into form input checkbox

20 views
Skip to first unread message

黄祥

unread,
Dec 2, 2020, 2:10:45 PM12/2/20
to web2py-users
views/form.html
<select id = "table_id" name = "table_id" title = "Table ID" onchange = "ajax('{{=URL(request.controller, target) }}', {{=field_list}}, 'target')" onselect = "jQuery('#month').val()" class = "form-control">
{{for row in rows:}}
<optgroup label = "{{=row.pitch_class}} Tones">
{{
for r in db(table.pitch_class == row.pitch_class).select(cache = cache_db, cacheable = True):
}}
<option value = {{=r.id}} {{='selected' if r.id == 22 else ''}}>
{{=", ".join([row_name for row_name in r.name] ) }}
</option>
{{pass}}
</optgroup>
{{pass}}
</select>

{{selected_table_id = jQuery('#table_id').val() }}
{{for i in range(1, selected_table_id + 1, 1):}}
<input name = "active_string" type = "checkbox" id = {{=i}} value = {{=i}}>
<label for = {{=i}}>{{=i}}</label>
{{pass}}

how to get the value of selected table_id then pass it into selected_table_id variable that can be used for input type checkbox in web2py way ?

thanks and best regards,
stifan
Reply all
Reply to author
Forward
0 new messages