疑问解答,另希望找到一好心的朋友能够指导我!
<%
int i = 0;
List<Object[]> list = (List<Object[]>)request.getAttribute("Invlist");
if (list != null) {
for (Object[] pro : list) {
pageContext.setAttribute("pro", pro);
i++;
%>
<tr onMouseOver="this.style.backgroundColor='#cccccc';"
onMouseOut="this.style.backgroundColor='ffffff';">
<td align="center" height="30">
<input id="CHK" value="<%=pro[0] %>" type=checkbox name="ids">
</td>
<td align="center">
<%=pro[1] %>
</td>
<td align="center" >
<%=pro[2].toString().substring(0,10) %>
</td>
<td align="center">
<%=pro[3].toString().substring(0,10) %>
</td>
<td align="center">
<%=pro[4] %>
</td>
<td align="center" >
<%=pro[5] %>
</td>
<td>
求2个TD的差
</td>
</tr>
获取pro4,pro5 2个TD的值,然后再算出这2个TD的差,希望大家帮忙看看,
问题简单,大家见笑了! 好心的朋友可以+我QQ,312456469
------解决方案--------------------如果你要用JavaScript获取就给两个td元素加上id属性值:
<script type="text/javascript">
function test(){
alert(isNaN("sfds"));
alert(isNaN("23"));
var centerId4 = document.getElementById("centerId4").value;
var centerId5 = document.getElementById("centerId5").value;
判断是数字就计算、不是数字就不计算
if(!isNaN(centerId4)&&!isNaN(centerId5)){
alert(Number(centerId4)-Number(centerId5));
}
}
</script>
如果你直接用java代码获取:
<%=Double.valueOf(pro[4].toString())-Double.valueOf(pro[5].toString()) %>