我有一个表单将值传递给django视图。
在表格中有一个带有复选框的动态生成表格。HTML复选框传递所有选定的内容值
HTML:
<table class="table table-striped">
<thead>
<tr>
<th><input type="checkbox" onClick="toggle(this, 'no')"></th>
<th>Order Id</th>
<th>Channel</th>
<th>Dispatch By Date</th>
<th>Amount</th>
<th>Status</th>
<th>Products</th>
</tr>
</thead>
<tbody>
{% for oid,oiid,dbd,stts,tp,sku,qty,chnl in new_orders %}
<tr>
<td><input type="checkbox" name="no" value="{{oid}}"></td>
<td>
<div><a class="btn-link" href="#">{{oid}}</a></div>
<div><input name="oiid" style="display:none" value="{{oiid}}">{{oiid}}</div>
</td>
<td>{{chnl}}<input name="channel" style="display:none" value="{{chnl}}"></td>
<td><span class="text-muted"><i class="fa fa-clock-o"></i> {{dbd}}</span></td>
<td>{{tp}}</td>
<td>{{stts}}</td>
<td>
<div>{{sku}}</div>
<div>Quantity: {{qty}}</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
我传递的3个值回我的看法。 oid, oiid, chnl
。 问题是,如果我选择了一些元素而不是全部,那么所有oid
的值都会传递给那些元素,但是oiid
和chnl
的值都会被传递。
我的javascript:
function toggle(source, text) {
checkboxes = document.getElementsByName(text);
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = source.checked;
}
}
如何通过只有被选择的全部三个变量的值?
所以...我的回答对你有帮助吗? – SatanicGeek