everyone let's look at the form submission of several ways of
code is as follows:


var EventUtil={
addHandler: function (element, the type, handler) {
if element. The addEventListener () {
element. The addEventListener (type of handler, false);
} else if (element. The attachEvent) {
element. The attachEvent (" on "+ type, handler);
} else {
element [type] "on" +=handler;

}},
getEvent: function (event) {
the return to the event? Event: the window. The event;
},
the preventDefault: function (event) {
if {event. The preventDefault ()
event. The preventDefault ();
} else {
event. ReturnValue=http://www.jb51.net//web/false;
}

}};
var form=document. GetElementById (" myForm ");
EventUtil. AddHandler (form, the "submit", function () {

//event object event=EventUtil. The getEvent (event);

//prevents the default event EventUtil. The preventDefault (event);
});

calls the preventDefault () method to prevent the form is submitted. In general, the form data is invalid and cannot be sent to the server, you can use this technology.
5, in JavaScript, to programmatically invoke the submit () method also can submit the form.
this way without having to form contains a submit button, any time can normal form is submitted. Look at an example:
var form=document. The getElementById (" myForm") ;
//submit the form
form. Submit ();
in order to call the submit () method when the form is submitted, the form of will not trigger a submit event, so remember to before calling this method validate form according to the number.
when the form is submitted, one of the biggest potential problems is to submit the form again. After the first form is submitted, if long time no reflect, users may become impatient. At that time, they might click the submit button again and again. Results tend to be very troublesome, because the server to deal with repeat request), or caused by error (if it is under the orders, so may many number).
to solve this problem, there are two
code is as follows:


<The script type="text/javascript" >
function validateForm () {
the if (the document. The reply. The title, value="" http://www.jb51.net//web/={//get the form by the form name
alert (" both please input the title!");
document. Reply. Title. The focus ();
return false;
}
the if (document) forms [0]. Cont. Value="" http://www.jb51.net//web/={//through forms array to obtain the form
alert (" both please input the content!");
document. Reply. Cont. The focus ();
return false;

} return true;
}
<The form name="reply" method="post" >
<Input type="text" name="title" size="80"/>

<The textarea name="cont" cols="80" rows="12" ></textarea>

<Input type="submit" value="http://www.jb51.net//web/to submit >"
</form>
note:
1. The onsubmit attribute content must have the return keyword, otherwise the function will be executed directly, will not return
2. ValidateForm must return a Boolean type of return value
3. The submit button to submit written type

method 2: use the input types for the submit components onclick () function of the form tag
will onsubmit=" Return validateForm () " Attributes to remove.
&other; Submit &throughout; Button to add the onclick event, as follows:
<Input type=" Submit" value=http://www.jb51.net//web/" Submit ">

  code is as follows:  


<The script type="text/javascript" >
function modifyItem () {
the if (trim (document. GetElementById (" itemName "). The value)=="") {
alert (" material name cannot be empty!");
document. GetElementById (" itemName "). The focus ();
the return;

} with the (document. GetElementById (" itemForm ")) {
method="post";
action="item do? The command=modify& pageNo=${itemForm. PageNo}";
the submit ();

}}
//return
function goBack () {
window. The self. The location="item. Do? The command=list& pageNo=${itemForm. PageNo}";
}
</script>
<The form name="itemForm" id="itemForm >"
<Input name="itemNo" type="text" id="itemNo" value="{item. ItemNo} http://www.jb51.net//web/$" >
<The input name="itemName" type="text" id="itemName" value="http://www.jb51.net//web/${item. ItemName}" >
<Input name="btnModify" type="button" id="btnModify value=http://www.jb51.net//web/“" Modify >"
</form>
note:
1. The submission time, setting the form action and the methods of the attribute, and then use the form. Submit () function to submit.

the above code implementation can refer to the following: http://www.bjp111.com/zhshlist.aspx

http://www.bjp111.com/huixiaolist.aspx

http://www.bjp111.com/daililist.aspx rookie summary# 0 - #


This concludes the body part