关于checkbox的全选功能
2011-10-11 13:44
330 查看
<script>
function selectAll()
{
var allCheckBox=document.getElementsByName("chkActivity");
for(i=0;i<allCheckBox.length;i++)
{
allCheckBox[i].checked=document.getElementById("selAll").checked;
}
}
function controlSel()
{
var allCheckBox=document.getElementsByName("chkActivity");
var firstCheckBox=document.getElementById("selAll");
var num=0;
for(i=0;i<allCheckBox.length;i++)
{
if(allCheckBox[i].checked)
{
num++;
}
}
if(num==allCheckBox.length)
{
firstCheckBox.checked=true;
}else
{
firstCheckBox.checked=false;
}
}
</script>
<table id="user_form:dataTableUser" cellspacing="0" class="simple"
width="100%" border="1" cellpadding="1" >
<tr>
<th class="simple">
<input type="checkbox" id="selAll" name="selAll" value="" onclick="javascript:selectAll();"/>
</th>
<th class="simple" style="width: 10%">
訂單編號
</th>
<th class="simple" style="width: 13%">
訂單狀態
</th>
<th class="simple" style="width: 7%">
客戶帳號
</th>
<th class="simple" style="width: 10%">
客戶姓名
</th>
<th class="simple" style="width: 10%">
運送區域
</th>
<th class="simple" style="width: 10%">
商品
</th>
<th class="simple" style="width: 10%">
數量
</th>
<th class="simple" style="width: 10%">
已出貨數量
</th>
<th class="simple" style="width: 10%">
應付金額
</th>
<th class="simple" style="width: 10%">
實付金額
</th>
</tr>
<s:iterator id="activity" value="queryResult" var="order"
status="stat">
<tr>
<td class="simple">
<input type="checkbox" name="chkActivity" value='<s:property value="pkey"/>' onclick="javaScript:controlSel();"/>
</td>
<td class="simple">
<s:a method="onLoad" name="orderNo" cssStyle="color:blue;">
<s:param name="pkeyOrderMain" value="pkey"></s:param>
<s:property value="orderNo"/>
</s:a>
</td>
<td class="simple">
<s:if test='status.equals("WaitCreditCard")'>待付款</s:if>
<s:elseif test='status.equals("CreditCardFail")'>刷卡失敗</s:elseif>
<s:elseif test='status.equals("WaitShipment")'>已付款</s:elseif>
<s:elseif test='status.equals("Shipped")'>訂單處理中</s:elseif>
<s:elseif test='status.equals("Close")'>已出貨</s:elseif>
<s:elseif test='status.equals("Cancel")'>訂單取消</s:elseif>
<s:else></s:else>
</td>
<td class="simple">
<s:property value="buyer.useremail" />
</td>
<td class="simple">
<s:property value="buyer.chtlastname"/><s:property value="buyer.chtfirstname"/>
</td>
<td class="simple">
<s:property value="consignee.town.townname" />
</td>
<td class="simple">
<s:iterator value= "orderDetails" id="line" var="line">
<s:property value="#line.activity.mainProduct.productName" />
</s:iterator>
</td>
<td class="simple">
<DIV align="right">
<s:set name="result" value="0"/>
<s:iterator value= "orderDetails" status="stat1">
<s:set name="result" value="#result + qty"/>
</s:iterator>
<s:property value="#result"/></DIV>
</td>
<td class="simple">
<DIV align="right">
<s:set name="total" value=""/>
<s:iterator value= "orderDetails" status="stat1">
<s:if
test='%{@org.apache.commons.lang.StringUtils@trimToEmpty(shippingDate) <> ""}'>
<s:set name="total" value="#total + qty"/>
</s:if>
</s:iterator>
<s:property value="#total"/>
</DIV>
</td>
<td class="simple">
<DIV align="right">
<s:text name="format.price"><s:param value="amount" /></s:text>
</DIV>
</td>
<td class="simple">
<DIV align="right">
<s:text name="format.price"><s:param value="amount+freight" /></s:text>
</DIV>
</td>
</tr>
</s:iterator>
</table>
<div id="pager" style="padding-top:5px">
</div>
function selectAll()
{
var allCheckBox=document.getElementsByName("chkActivity");
for(i=0;i<allCheckBox.length;i++)
{
allCheckBox[i].checked=document.getElementById("selAll").checked;
}
}
function controlSel()
{
var allCheckBox=document.getElementsByName("chkActivity");
var firstCheckBox=document.getElementById("selAll");
var num=0;
for(i=0;i<allCheckBox.length;i++)
{
if(allCheckBox[i].checked)
{
num++;
}
}
if(num==allCheckBox.length)
{
firstCheckBox.checked=true;
}else
{
firstCheckBox.checked=false;
}
}
</script>
<table id="user_form:dataTableUser" cellspacing="0" class="simple"
width="100%" border="1" cellpadding="1" >
<tr>
<th class="simple">
<input type="checkbox" id="selAll" name="selAll" value="" onclick="javascript:selectAll();"/>
</th>
<th class="simple" style="width: 10%">
訂單編號
</th>
<th class="simple" style="width: 13%">
訂單狀態
</th>
<th class="simple" style="width: 7%">
客戶帳號
</th>
<th class="simple" style="width: 10%">
客戶姓名
</th>
<th class="simple" style="width: 10%">
運送區域
</th>
<th class="simple" style="width: 10%">
商品
</th>
<th class="simple" style="width: 10%">
數量
</th>
<th class="simple" style="width: 10%">
已出貨數量
</th>
<th class="simple" style="width: 10%">
應付金額
</th>
<th class="simple" style="width: 10%">
實付金額
</th>
</tr>
<s:iterator id="activity" value="queryResult" var="order"
status="stat">
<tr>
<td class="simple">
<input type="checkbox" name="chkActivity" value='<s:property value="pkey"/>' onclick="javaScript:controlSel();"/>
</td>
<td class="simple">
<s:a method="onLoad" name="orderNo" cssStyle="color:blue;">
<s:param name="pkeyOrderMain" value="pkey"></s:param>
<s:property value="orderNo"/>
</s:a>
</td>
<td class="simple">
<s:if test='status.equals("WaitCreditCard")'>待付款</s:if>
<s:elseif test='status.equals("CreditCardFail")'>刷卡失敗</s:elseif>
<s:elseif test='status.equals("WaitShipment")'>已付款</s:elseif>
<s:elseif test='status.equals("Shipped")'>訂單處理中</s:elseif>
<s:elseif test='status.equals("Close")'>已出貨</s:elseif>
<s:elseif test='status.equals("Cancel")'>訂單取消</s:elseif>
<s:else></s:else>
</td>
<td class="simple">
<s:property value="buyer.useremail" />
</td>
<td class="simple">
<s:property value="buyer.chtlastname"/><s:property value="buyer.chtfirstname"/>
</td>
<td class="simple">
<s:property value="consignee.town.townname" />
</td>
<td class="simple">
<s:iterator value= "orderDetails" id="line" var="line">
<s:property value="#line.activity.mainProduct.productName" />
</s:iterator>
</td>
<td class="simple">
<DIV align="right">
<s:set name="result" value="0"/>
<s:iterator value= "orderDetails" status="stat1">
<s:set name="result" value="#result + qty"/>
</s:iterator>
<s:property value="#result"/></DIV>
</td>
<td class="simple">
<DIV align="right">
<s:set name="total" value=""/>
<s:iterator value= "orderDetails" status="stat1">
<s:if
test='%{@org.apache.commons.lang.StringUtils@trimToEmpty(shippingDate) <> ""}'>
<s:set name="total" value="#total + qty"/>
</s:if>
</s:iterator>
<s:property value="#total"/>
</DIV>
</td>
<td class="simple">
<DIV align="right">
<s:text name="format.price"><s:param value="amount" /></s:text>
</DIV>
</td>
<td class="simple">
<DIV align="right">
<s:text name="format.price"><s:param value="amount+freight" /></s:text>
</DIV>
</td>
</tr>
</s:iterator>
</table>
<div id="pager" style="padding-top:5px">
</div>
相关文章推荐
- 关于checkbox的全选和反选功能
- 关于Repeater中嵌套GridView以及GridView中checkbox的全选功能的实例
- 关于用jQuery实现的checkbox全选和反选功能
- checkbox全选功能js
- 关于GridView中的CheckBox全选,取消一段JavaScript脚本
- JS:支持任意数量的分组checkbox全选功能(几种方法的比较)
- checkbox全选功能javascript实现
- JTable中 表头中添加 JCheckBox 全选 功能
- GridView中实现类邮件的CheckBox全选功能
- jQuery实现checkbox三种情况的全选功能
- jquery 实现checkbox全选,反选,全不选等功能代码(奇数)
- checkbox全选功能
- 关于checkbox的全选/全不选的处理
- jquery checkbox全选功能
- 一个较简单的js实现checkbox的全选与全不选功能
- 实现前端table中checkbox全选功能,并将选中的数据发送到后端
- 原创 c# 封装的带CheckBox的DataGridViewColumnHeaderCell 源码部分 实现DataGridView列头带CheckBox控件实现全选功能,支持列头带标题
- JS:&quot;全选&quot;功能实现(checkbox)
- 点滴积累【JS】---JS小功能(checkbox实现全选和全取消)
- jquery 实现gridview checkbox 全选功能