您的位置:首页 > Web前端 > JavaScript

javascript 数据库取数据 全选和反选

2010-05-04 19:48 253 查看
javascript所对应的全选和反选 。操作数据库记录。

以下是页面代码:

<tr>
<td colspan="6" width="100%">
<table border="2" width="100%">
<tr class="center">
<th width="20%" class="center">
全选/反选<input type="checkbox" name="all"
onclick="ckeckAll(this);">
</th>
<th width="20%" class="center">
箱主
</th>
<th width="20%" class="center">
箱号
</th>
<th width="20%" class="center">
箱型
</th>
<th width="20%" class="center">
箱类
</th>
</tr>
<tbody id="listTable">
<logic:iterate id="ylxhlist" name="lssqdListForm"
property="ylxhlist"
indexId="index">
<%
int i=index.intValue();
%>
<tr>
<th width="20%" class="center">
<html:checkbox property="checkbox1" name="ylxhlist"
value="true" indexed="true"/>
<html:hidden name="ylxhlist" property="id" indexed="true"
/>
<html:hidden name="ylxhlist" property="zbid"
indexed="true" />
<html:hidden name="ylxhlist" property="xxdm"
indexed="true" />
<html:hidden name="ylxhlist" property="xldm"
indexed="true" />
<html:hidden name="ylxhlist" property="ztmc"
indexed="true" />
<html:hidden name="ylxhlist" property="ztid"
indexed="true" />
</th>
<td width="20%" class="center">
<bean:write name="ylxhlist" property="xzdm" />
<html:hidden name="ylxhlist" property="xzdm"
indexed="true" />
</td>
<td width="20%" class="center">
<bean:write name="ylxhlist" property="xhdm" />
<html:hidden name="ylxhlist" property="xhdm"
indexed="true" />

</td>
<td width="20%" class="center">
<bean:write name="ylxhlist" property="xxmc" />
<html:hidden name="ylxhlist" property="xxmc"
indexed="true" />
</td>
<td width="20%" class="center">
<bean:write name="ylxhlist" property="xlmc" />
<html:hidden name="ylxhlist" property="xlmc"
indexed="true" />
</td>
</tr>
</logic:iterate>
</tbody>

</table>
</td>
</tr>


所对应的javascript代码如下:

//全选。
function ckeckAll(obj){
var checkboxs = document.getElementsByName("all");
var ob = document.getElementById("listTable");
for ( var i = 0; i < ob.rows.length; i++) {
var oTr = ob.children[i];
var oCheckbox = oTr.children[0].children[0];
if(obj.checked){
oCheckbox.checked=true;
}else{
oCheckbox.checked=false;
}
}

}


可以实现全选和反选。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: