我有一个带复选框和分页的html表格,我的问题是我只能从当前页面中选择对象..任何人都可以帮助我吗?
<form action="{% url 'tag:selected' %}" method="get">
<table id="dt" class="table table-bordered table-hover responsive" style="text-align:center;">
<thead>
<tr>
<th><input type="checkbox" onClick="toggle(this)"></th>
<th></th>
<td>Name</td>
<td>Frequency</td>
<td>Environment</td>
<td>Peak Temperature</td>
<td>Mounting Method</td>
<td>Standards</td>
<td>Memory</td>
</tr>
</thead>
<tbody>
{% for tags in all_tags %}
<tr>
<td><input type="checkbox" name="selected" value="{{ tags.id}}"></td>
<td><a href="{% url 'tag:detail' tags.id %}"> <img src="{{ tags.tag_image.url }}" style="display:block;
width: 80px; height:80px; margin:auto;"></a></td>
<td>{{ tags.tag_name }}</td>
<td>{{ tags.tag_frequency}}</td>
<td>{{ tags.tag_environment }}</td>
<td>{{ tags.tag_peak_temperature }}</td>
<td>{{ tags.tag_mounting_method }}</td>
<td>{{ tags.tag_standards }}</td>
<td>{{ tags.tag_memory }}</td>
</tr>
{% endfor %}
</tbody>
</table><input class="btn btn-primary" style="float:right; margin-right:5%; margin-bottom:2%; margin-top:-3%; "type="submit" value="Submit">
</form>
这是我的复选框javascript代码:
<script language="JavaScript">
function toggle(source) {
checkboxes = document.getElementsByName('selected');
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = source.checked;
}
}
</script>
答案 0 :(得分:-1)
所以你需要jquery datatable中的特征行的复选框,如下所述 https://www.gyrocode.com/articles/jquery-datatables-how-to-add-a-checkbox-column/