日期:2014-05-17 浏览次数:20743 次
<%@ page contentType="text/html;charset=GB2312"%> <html> <head> <title>当前页面验证</title> </head> <script type="text/javascript" > // document.getElementsByName("ba")[0].value = ""; function test1() { document.getElementsByName("yanzh")[0].value="b1"; bd1.submit(); } function test2() { document.getElementsByName("yanzh")[0].value="b2"; bd1.submit(); } </script> <body> <form name="bd1" method="post" > <input type="text" name = "yanzh" style="display:none"/> <input type="button" value="按钮1验证" onclick = " test1()"/> <input type="button" value="按钮2验证" onclick = " test2()"/> <input type="text" name="text1" id = "wb1" /> <% String b = request.getParameter("yanzh"); if (b=="b1") out.print("<script>alert('按钮1验证!');</script>"); else if (b=="b2") out.print("<script>alert('按钮2验证!');</script>"); else out.print("<script>alert('显示b值:"+b+"');</script>"); %> </form> </body> </html>
if ("b1".equals(b)) out.print("<script>alert('按钮1验证!');</script>"); else if ("b2".equals(b)) out.print("<script>alert('按钮2验证!');</script>"); else out.print("<script>alert('显示b值:"+b+"');</script>");
------解决方案--------------------