django复选框全部选中 [英] django checkbox select all
本文介绍了django复选框全部选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过javascript?怎么样?
我可以用简单的方法做到这一点吗?
谢谢:D
run.html
; form name =formmethod =postaction =/ home / {{build}} />
< br>
< input type =submitvalue =Deletestyle =margin-left:149px; width:80px; height:30px>
< input type =hiddenname =build_idvalue ={{build_id}}/>
< table border =1; style =margin-left:150px; border-collapse:collapse; margin-top:10px; cellpadding =4borderColor = black>
< tr bgcolor =#888888>
< td>< input type =checkboxalign =center>< / td>
< td>< b>运行< / b>< / td>
< td>< b> Product< / b>< / td>
< / tr>
{%运行在run_list%}
< tr>
< td>< input type =checkboxname =var_deletevalue ={{run.id}}>< / td>
< td>< a href =/ home / {{build}} / {{run.name}}> {{build}} {{run.name}}< / a& < / TD>
< td> {{run.build.version}}< / td>
< / tr>
{%endfor%}
< / table>
< / form>
解决方案
你必须使用javascript。这是一个使用jquery的例子。
$(。checkbox_delete)。attr('checked',true)
将其放在头文件的点击事件复选框中,并将该类(checkbox_delete)添加到所有复选框你要检查。
how can i select all checkbox when i click header checkbox? By javascript? How? And can i do that in easier method? thanks:D
run.html
<form name="form" method="post" action="/home/{{build}}/">
<br>
<input type="submit" value="Delete" style="margin-left:149px; width:80px; height:30px">
<input type="hidden" name="build_id" value="{{build_id}}" />
<table border="1"; style="margin-left:150px; border-collapse:collapse;margin-top:10px"; cellpadding="4" borderColor=black>
<tr bgcolor=#888888>
<td><input type="checkbox" align="center"></td>
<td><b>Run</b></td>
<td><b>Product</b></td>
</tr>
{% for run in run_list %}
<tr>
<td><input type="checkbox" name="var_delete" value="{{run.id}}"></td>
<td><a href="/home/{{build}}/{{run.name}}">{{build}} {{run.name}}</a></td>
<td>{{run.build.version}}</td>
</tr>
{% endfor %}
</table>
</form>
解决方案
You have to use javascript for that. This is an example using jquery...
$(".checkbox_delete").attr('checked', true);
put that in the click event of the header checkbox and add that class (checkbox_delete) to all the checkboxes you want checked.
这篇关于django复选框全部选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文