"JS Notes" Magic JS to convert a tag to a super-strong submit button

Source: Internet
Author: User

The headline might say a little pompous 0.o

In the previous page, the Submit button in the form form was written

<type= "Submit"/>

However, always feel that there is no easy-to-set style, so write a JS function to convert the a tag to the Submit button.

First on the code:

JS Code:

  The A tag can be used to submit a form (form) JS function  //  Applies to multiple submit cases in a form  function   Tosubmit (action_str) { );  if  (Action_str==null  ) {Myform.submit ();  else  {myform.action  = Action_str;    Myform.submit ();  return  false;     

How to use:

<formAction= "Action Address"class= "MyForm"ID= "MyForm">                    <inputname= "Searchcontent"value= "${searchcontent}"type= "text" />                    <Divclass= "Search-list">                    <ahref="#"class= "Search-btn"onclick= "Tosubmit (' Action Address 1 ')">Search 1</a>                            <ul>                                    <Li><ahref="#"onclick= "Tosubmit (' Action Address 2 ')">Search 2</a></Li>                                    <Li><ahref="#"onclick= "Tosubmit ()">Search 3</a></Li>                            </ul>                    </Div>                    </form>

Description

1. Set the href in the A tag to "#";

2. Set Oclick to invoke the JS function, and if you fill in the parameters, jump to the specified action

3. Default if no parameter is jump to form action

"JS Notes" Magic JS to convert a tag to a super-strong submit button

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.