Form form, submit toggle Submit

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.