|
|
<SCRIPT ...>FOR = "object ID"EVENT = event name| Usage Recommendation |
|---|
| don't use it |
FOREVENTonsubmit() event handler for the object whose ID is myform:
<SCRIPT TYPE="text/javascript" FOR="myform" EVENT="onsubmit()">
<!--
var response=confirm("are you sure you want to submit?");
return response;
//-->
</SCRIPT>
The script is then applied to a form by setting the form's ID to
myform:
<FORM ACTION="../cgi-bin/mycgi.pl" ID="myform"> name: <INPUT NAME="realname"><BR> email: <INPUT NAME="email"><BR> <INPUT TYPE=SUBMIT VALUE="join"> </FORM>
which (in MSIE) gives us this form:
This technique for setting an event handler isn't any easier than the traditional method which is also much more universal. Any object that has an event can have that event set with the appropriate attribute. For example, to set our form to check if the user really wants to submit we can use a script function and the
onSubmitsubmitconfirm():
<SCRIPT TYPE="text/javascript">
<!--
function submitconfirm()
{
var response=confirm("are you sure you want to submit?");
return response;
}
//-->
</SCRIPT>
The form would call submitconfirm() in
onSubmit
<FORM
ACTION="../cgi-bin/mycgi.pl"
onSubmit="return submitconfirm()">
name: <INPUT NAME="realname"><BR>
email: <INPUT NAME="email"><BR>
<INPUT TYPE=SUBMIT VALUE="join">
</FORM>
which gives us this form (try submitting it):
|
Recommended Resources |
|||
| web hosting tutorials Credit Help |
Search the Internet Search Engine Help |
Low Fat Lifestyle Internet Traffic |
Web
Hosting Web Design |
|
Discount
Hotel Reservations All
Rights Reserved, Copyright © Free-HTML-Tutorials.com 2003 |
|||