1.把对应的jQuery包导入进来。页面加载时,加入jQuery初始化。首先是得到表格的id,然后再调用jQuery插件中的dataTable()方法即可。如下所示
表格标准格式:
2.JavaScript选择框选择问题。首先在一个页面中添加一个select控件,然后在父页面打开一个新页面,称为子页面。在此页面中添加checkbook控件,在子页面中点击checkbook时,把对应的值填入父页面中select控件去。实现代码如下:
$(function() {
$('#tableID').dataTable();
});
表格标准格式:
<table id="tableid">
<thead>
<th></th>
<th></th>
<th></th>
</thead>
</tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
2.JavaScript选择框选择问题。首先在一个页面中添加一个select控件,然后在父页面打开一个新页面,称为子页面。在此页面中添加checkbook控件,在子页面中点击checkbook时,把对应的值填入父页面中select控件去。实现代码如下:
<script type="text/javascript">
<!--
$(function() {
$('#tableID').dataTable();
});
function selectBoxClick(id, name, checkBox){
if(checkBox.checked == true) {
addrole(id, name);
} else {
notAddRole(id);
}
}
function addrole(id, name){
self.opener.addrolepoint(id, name);
}
function notAddRole(id){
var list = self.opener.document.getElementById('role_ids');
var maxCnt = list.options.length;
for(var i = maxCnt - 1; i >= 0; i--){
if ((list.options[i] != null) && (list.options[i].value == id)){
list.options[i] = null;
}
}
}
function addrolepoint(id, name){
var groupIds = window.document.getElementById('role_ids');
var newplace = groupIds.options.length;
if (newplace > 0 && groupIds.options[0].value == ""){
newplace = 0;
}
for (var i = 0; i < groupIds.options.length; i++){
if (groupIds.options[i].value == id){
newplace = -1;
}
}
if (newplace > -1){
groupIds.options[newplace] = new Option(name + " (" + id + ")", id);
}
}
-->
</script>