Home>
<! Doctype html public "-//w3c //dtd xhtml 1.0 strict //en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>untitled document</title>
</head>
<body>
<script>
function test ()
{
  document.getelementbyid ("myform"). submit ();
  alert (11);
}
</script>
<form name="myfrom" method="get" action="b.php">
<input type="text" name="pwd" value="" />
<input type="submit" name="sub" value="111" />
<input type="button" name="btn" value="btn" onclick="test ()" />
</form>
</body>
</html>

Note:When submitting the form with the get method, you cannot use url to pass the value in the action. Post can pass it this way.

Difference between js submit and submit button submission:

1.JS does not take the value of submit button when submitting the form (because it is not clicked) All browsers

2. Enter and submit. The w3c browser will bring the value of the submit button.ie6 will not bring

Solution:

Add a hidden domain, use this to judge,No matter which way you submit it will have value

Bind the submit event on the submit button:

That is:<input type="submit" name="btn" value="btn" onclick="test ()" />

Will bring the value of submit, the onsubmit status cannot be detected with js submission

w3c:Submit once

ie6:two submissions,First js submit in form

Solution:

If the button is submit, use the onsubmit event to detect

If the button is a button, the submit event is triggered after the detection passes.

Don't submit forms with js,Then use onsubmit to detect

Simply submit the form with js, alert, ff blocking form submission,While others browse

  • Previous Summary of js operation array function examples
  • Next Three ways SpringMVC returns json data