2015-01-14 42 views
0

我想调用javascript函数,但不是调用javascript函数,而是通过访问SERVLET来重定向到另一个JSP页面。 我发现了一个链接的帮助,他也使用了与我一样的过程。来自JSP的javascript调用

链接,我发现:javascript function in jsp page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Welcome</title> 

</head> 
<body> 
    <script type="text/javascript"> 
     function callCommom() { 
      alert("Method Called"); 
      return (false); 
     } 
    </script> 
    <form action="Common" method="post" onsubmit="return callCommon()"> 
     <table align="center" border="1"> 
      <tr> 
       <td align="center">Assignment</td> 
      </tr> 
      <tr> 
       <td> 
        <table align="center" border="1"> 
         <tr> 
          <td><label>Assignment Number</label></td> 
          <td><input type="text" name="assnName" id="assnname"> 
          </td> 
         </tr> 
         <tr> 
          <td align="center"><input type="submit" value="submit"></td> 
          <td align="center"><input type="button" name="btnClear" 
           id="clearButton" value="Clear"></td> 
         </tr> 
        </table> 
       </td> 
      </tr> 
     </table> 
    </form> 
</body> 
</html> 

请建议我......我需要你的帮助。

+0

你们是不是提交给servlet之前验证在JavaScript形式或实际上,你并不要提交给servlet呢? – developerwjk

+0

您可以使用onclick上的提交按钮调用相同的功能 – Prashant

回答

1

有一个排字错误错误。必须是:

<form action="Common" method="post" onsubmit="return callCommom()"> 
                  ^

或者:

function callCommon() { 
       ^
+0

OMG !!非常感谢你......我打破了我的头,但我没有注意到它。 :) – Brain

+1

不客气。 - 别担心。这些事情发生。很高兴提供帮助。 :) –