jquery表格插件及JavaScript选择框

1.把对应的jQuery包导入进来。页面加载时,加入jQuery初始化。首先是得到表格的id,然后再调用jQuery插件中的dataTable()方法即可。如下所示
   $(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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值