redhobor
发贴: 5
|
于 2005-03-10 18:28
对javascript不熟,弄了半天没结果,只好求教于各位老大了。 <script language="javascript" type=""> <!-- //This function processes events of update or delete user function sendData(num){ if(num=='1'){ document.frm.action="updateuser.jsp"; } else if(num=='2'){ document.frm.action="deleteuser.jsp"; } document.frm.submit(); } <center> <form name="frm" method="post"> <table width="75%" border="0"> <tr bgcolor="#CCCCCC"> <td> </td> <td>ID</td> <td>Surname</td> <td>Forename</td> <td>Privilege</td> </tr> <% ResultSet rs = (ResultSet) request.getAttribute("userinfo"); while (rs.next()) { usr_id = rs.getString("usr_id"); usr_surname = rs.getString("usr_surname"); usr_forename = rs.getString("usr_forename"); usr_privilege = rs.getString("usr_privilege"); out.print("<tr><td><input type=\"checkbox\" name=\"usr_id\" value=\"" + usr_id + "\"></td>"); out.print("<td>" + usr_id + "</td>"); out.print("<td>" + usr_surname + "</td>"); out.print("<td>" + usr_forename + "</td>"); out.print("<td>" + usr_privilege + "</td></tr>"); } rs.close(); %> </table> <p> </p> <p> <input type="button" name="adduser" value="Add" onclick="doChange()"> <input type="submit" name="updateuser" value="Update" onclick="sendData('1')"> <input type="submit" name="deleteuser" value="Delete" onclick="sendData('2')"> </p> </form> CHECKBOX在Update时只能选取一个,而在删除时可以选择多个。所以我想了解用javascript方法来取到已经Checked的类别的个数。在Submit时,可以即时判断并显示window.alert()
|