如何通过复选框获取整行数据,详细内容见代码
<tbody id="checkList">
<logic:notEmpty name="jshList">
<logic:iterate id="JSHcash" name="jshList" indexId="ind">
<logic:equal property="evenPrice" name="JSHcash" value="0" >
<logic:notEqual property="tranState" name="JSHcash" value="取消">
<tr>
<!-- 取消的信息 标红,未导入标表黄 -->
<td align="center"><INPUT type='checkbox' name='txnNo' value='<bean:write name="JSHcash" property="txnSerialNo" format="#" />'/></td>
<td id="orgName" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="orgName" format="#" /></td>
<td id="tradeName" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="tradeName" format="#" /></td>
<td id="tranState" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="tranState" format="#" /></td>
<td id="launchDate" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="launchDate" format="yyyy-MM-dd HH:mm:ss"/></td>
<td id="finishedDate" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="finishedDate" format="yyyy-MM-dd HH:mm:ss"/></td>
<td id="currentBizNo" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="currentBizNo" format = "#"/></td>
<td id="fromCurSign" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="fromCurSign" /></td>
<td id="fromAmt" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="fromAmt" format="#.##"/></td>
<td id="toCursign" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="toCursign" /></td>
<td id="toAmt" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="toAmt" format="#.##"/></td>
<td id="spfeSubject" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="spfeSubject" format="#" /></td>
<td id="parities" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="parities" format="#.######" /></td>
<td id="insidePrice" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="insidePrice" format="#.######" /></td>
<td id="convertPrice" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="convertPrice"format="#.######" /></td>
<td id="tradePrice" bgcolor="yellow"><bean:write name="JSHcash" property="tradePrice" format="#.######" /></td>
<td id="evenPrice" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="evenPrice" format="#.##" /></td>
<td id="partProfit" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="partProfit" format="#.##" /></td>
<td id="headProfit" align="center" bgcolor="yellow"><bean:write name="JSHcash" property="headProfit" format="#.##" /></td>
</tr>
</logic:notEqual>
</logic:equal>
</logic:iterate>
</logic:notEmpty>
</tbody>
代码如上:
系统通过选中复选框,不提交表单的情况下在javascript中获取到选中行的值。
上面循环的内容还有两块,标不同的颜色,那样ID会重复,导致无法取出数据。
大侠速度解答。马上结贴走人
[解决办法]
标签可以给每个tr一个id ,得到id后 判断下什么情况下什么样色,用jquery添加此行tr的class样式 不就行了么
[解决办法]
var table = document.all.checkList; //准确的讲是table的id而不是tbody的id
var lie = table.rows(0).cells.length ; //获取table有多少列
var cb = document.getElementByID("txnNo") ;
var i=1 ;
循环 判断cb.checked i++ ;
判断行
根据 j<lie 循环得到 table.rows(i).cells(j).innerText //获取table 中单个td的text
[解决办法]
给你的input标签加一个id,如id=“mm”
js中 var n=document.hetElenmentById(“id的值”).value;
再根据这个n的值去数据库再取,或者直接与你返回到页面上的集合进行判断,当n的值与你集合中的对象中的txnSerialNo属性的值相等的话就将该对象取出,一条数据(一行的数据)就是一个对象哦