JS 表单submit() 提交无效的问题

<script>
 window.onload = login;
 function login(){
  document.getElementById("username").value = '<?php  echo $_COOKIE["username"]; ?>';
  document.getElementById("password").value = '<?php  echo $_COOKIE["password"]; ?>';
  document.getElementById("loginForm").submit();
 }
</script>

 <form id="loginForm"  action="index.php?user-login" method="post" >
  <input  id="username"    type="text" />
  <input  id="password"    type="password" />
  <input name="submit" type="submit" value="登录"/>
</form>

=======================================

JS 方法中的 submit() 不执行  页面没有跳转。

在群里 网友 帮我解答了。  很感谢。

<input name="submit" ,按钮的名字不要取成关键字
你调用submit()的时候,JS不会执行,因为有的名字叫submit

posted @ 2013-04-24 17:34  幻星宇  阅读(1606)  评论(0编辑  收藏  举报