form.submit()不能提交表单的原因分析
直接上代码把:
<divid="register"> <h4>会员注册</h4> <divclass="formdiv"> <formmethod="post"action="register.php?action=register"name="register"id="registerForm"> <dl> <dt>请认真填写以下内容</dt> <ddclass="hasspan"> 用户名:<inputtype="text"name="username"> </dd> <ddclass="hasspan"> 密码:<inputtype="password"name="pwd"> </dd> <ddclass="hasspan"> 确认密码:<inputtype="password"name="pwdagain"> </dd> <ddid="tximg"> <imgsrc="img/face/m01.gif"alt="选择头像"id="faceimg"> <inputtype="hidden"name="touxiang"value=""> <labelid="imgsrclabel">m01.gif</label> </dd> <ddstyle="margin-right:120px;"> 验证码:<inputtype="text"name="code"> <span> <imgsrc="code.php"alt="code"id="code"name="code"> <ahref="#code"id="change">换一张</a> </span> </dd> <ddclass="btns"> <inputtype="button"name="submit"id="submit"value="注册"> <inputtype="button"name="quit"id="quit"value="退出"> </dd> </dl> </form> </div> </div>
表单数据提交到本页面,下面是js处理
/*注册表单提交*/ functionformDeal() { varbtnSubmit=document.getElementById('submit'); varformId=document.getElementById('registerForm'); btnSubmit.onclick=function() { //表单的submit()方法不能提交表单 formId.submit(); }
}