2012-05-01 198 views
1
function formv(frm){ 

    alert(frm.username.value); 

    document.myform.submit(); 
} 

<form action="http://localhost/CI/index.php/scontr/logs" method="post" name="myform"> 
     <fieldset> 
     <table> 
      <tr> 
       <td>UserID:</td> 
       <td><input type="text" name="username" maxlength="30" value="" /></td> 
      </tr> 
      <tr> 
       <td>Password:</td> 
       <td><input type="password" name="password" maxlength="30" value="" /></td> 
      </tr> 

          <tr><td> 
          <select name="myselect"> 
          <option value="one" >Teacher</option> 
          <option value="two" >Student</option> 
          </select></td> 
          </tr> 

      <tr> 

       <td colspan="2"><input type="button" name="submit" onclick="formv(this.form)" value="Login" /></td> 
      </tr> 

谁能告诉我为什么上面的表格不会被张贴在以下地址。显示警告框,但没有任何反应。它仍然在同一页JavaScript错误提交HTML表单提交

+0

你得到在浏览器的错误控制台错误? – kevin628

+0

其说document.myform.submit不是函数 – user1366645

+0

尝试使用document.forms [0] .submit() –

回答

0

您需要重命名您的提交按钮,因为document.myform.submit现在引用按钮而不是提交操作。

变化

name="submit" 

name="btnSubmit" 
+0

thanks.this帮助 – user1366645