- HTML code
<%@ page language="java" import="java.util.*,com.bean.*" pageEncoding="GBK"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <script language="javascript" type="text/javascript"> function doDelete(){ form1.action="deletedwdo.jsp"; form1.target="downFrame"; form1.submit(); } function showmore(){ var sel_id=form1.sel_id.value; window.alert(sel_id); window.showModalDialog("display_more_dw.jsp?sel_id="+sel_id,window,"status:no;scroll:yes;dialogWidth:710px;dialogHeight:500px;center:yes"); } </script> </head> <body> <big><strong>单位信息</strong></big> <hr /> <form id="form1" name="form1" action="updatedw.jsp" method="post" target="mainFrame"> <table width="100%" border="1"> <tr> <th>编号 </th><th>单位编号</th><th>单位名称</th><th>工商执照号码</th><th>组织机构代码</th> </tr> <% List lstbc =(List)request.getAttribute("lstbc"); if(lstbc!=null){ Iterator it=lstbc.iterator(); while(it.hasNext()){ Dwjbxx tempbc=(Dwjbxx)it.next(); %> <tr> <td align="center"> <input type='radio' id="sel_id" name="sel_id" value=<%=tempbc.getId()%> checked="checked" /> </td> <td align="center"><%=tempbc.getDwbh()%></td> <td align="center"><%=tempbc.getDwmc()%></td> <td align="center"><%=tempbc.getGsdjzzhm()%></td> <td align="center"><%=tempbc.getZzjgdm()%></td> <td align="center"><%=tempbc.getZzjgdm()%></td> </tr> <% } } %> </table> <table> <tr> <th align="center"> <input type="button" value="查看详细单位信息" onclick="showmore()" /> </th> <th align="center"> <input type="submit" value="修改单位信息" /> </th> <th align="center"> <input type="button" value="删除单位信息" onclick="doDelete()"> </th> </tr> </table> </form> </body></html>
------解决方案--------------------
因为你迭代时候 得到的内容的有很多不只是一个
- JScript code
var e = document.getElementsByTagName("input"); var hasNoneChecked = true;for (var i = 0; i < e.length; i++) { if (e[i].type == 'checkbox' && e[i].checked ) { hasNoneChecked = false; alert(e[i].value); } } if (hasNoneChecked) { return alert("请选择一个!"); }else{ //dosomething; }
------解决方案--------------------