Sometimes encounter with form form to submit data, and then the same form under the submission of two kinds of information, for example, four input, are in a form, submit two, one is login, one is registered, this time we need to verify, what I point is to register or login to submit. The form code is as follows.
<formAction= "Login.do"name= "Form1" > <Divclass= "Login-hidd"></Div> <Divclass= "Login-wrap"> <Divclass= "Login-cont"> <DivID= "Qiehuan"> <inputtype= "button"name= "Login-button"ID= "Login-button"value= "Login"/> <inputtype= "button"name= "Register-button"ID= "Register-button"value= "Register"/> </Div> <Divclass= "Lx-input-all"> <Divclass= "Login-div-tel"> <spanclass= "Login-tip">Mobile Number:</span> <inputname= "Tel"ID= "Logininputtell"type= "text"class= "Login-input-tel defaultborder"><BR/><labelID= "Errortel"style= "Display:none">${errortel}</label> <labelID= "ERRORTELR"style= "Display:block">${ERRORTELR}</label> </Div> <Divclass= "LOGIN-DIV-PASSWD"> <spanclass= "Login-tip">Password:</span> <inputname= "Password"ID= "Logininputpwd"type= "Password"class= "LOGIN-INPUT-PASSWD"> </Div> <Divclass= "Login-div-passwd2"> <spanclass= "Login-tip">Confirm Password:</span> <inputID= "LoginInputPwd2"type= "Password"class= "LOGIN-INPUT-PASSWD"> </Div> </Div> <Divclass= "Login-div-submit"> <Buttontype= "Submit"ID= "Login-button-login"onclick= "checkaction (1);">Landing</Button> <Buttontype= "Submit"ID= "Login-button-register"onclick= "checkaction (0);">Registered</Button> </Div> </Div> </Div> </form>
Add the onclick event in the submit, place the function with the parameter, point login is passed into 1, point registration is passed into 0, in the above judgment, the code is as follows
<Scripttype= "Text/javascript"> functionCheckaction (v) {if(v==0) {alert ('from registering into'); Document.form1.action="register.do"; }Else{alert ('from landing into'); Document.form1.action="login.do"; }); } form1.submit (); } </Script>
OK, here's how to switch the commit information.
Form form, submit toggle Submit