Front-end technology-submit a form through javaScript, front-end javascript

Source: Internet
Author: User

Front-end technology-submit a form through javaScript, front-end javascript

window.location=pp+"?username="+getCookie("username")+"&userid="+getCookie("userid");

Replace


document.write("<form action="+pp+" method=post name=formx1 style='display:none'>");document.write("<input type=hidden name=username value='"+getCookie("username")+"' />");document.write("<input type=hidden name=userid value='"+getCookie("userid")+"' />");document.write("</form>");document.formx1.submit();




How to control the submission form in javascript

<Form name = "form" method = "post" action = "">
<Input type = "button" value = "delete" onClick = "delall ();" class = "button">
</Form>
<Script language = "javascript">
Function delall (){
If (confirm ('Are you sure you want to delete the selected consultation? \ N Note: it cannot be restored after deletion! ')){
This. form. action = "UserReview. asp? Action = delall "// set the Handler
This. form. submit (); // submit the form
}
}
</Script>

Note that the button is not submit.

If it is a submit, you must add onSubmit = "delall ()" to the <form tag ()"

How does JavaScript submit a form?

Html:
<Form name = "abc" id = ""
---------------
Js:
1. document. abc. submit ()
2. document. getElementById ("")
3. If there is only one form on the current page
Document. froms [0]. submit ()
4. document. froms ["abc"]. 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.