|
|
onMouseOver, onMouseOut Events |
|
|
onClick, onChange Events Handlers |
|
|
Using the onSubmit Event Handler |
| onMouseOver, onMouseOut Events |
You commonly use onMouseOver event with
anchor tags (<A>) to provide
additional information about the link. The onMouseOut event,
then, generally undoes what the onMouseOver event does. Using
these event handlers, you can, among other things, implement
timed status bar events, swap images, and alert visitors.
Example :
<A HREF= " http://www.layoutgalaxy.com/
" onMouseOver = "window.status
= 'Check us out!' " onMouseOut = "window.status=' '; return
true">Visit the Layout Galaxy site. </A>
| onClick, onChange Events Handlers |
You can use onClick and onChange handlers,
which are activated when visitors click an object or a button
or change a form field. Including these event handlers is
similar to using the onMouseOver and onMouseOut event handlers.You
can use the onChange or the onClick event handler to set link
destinations in forms, among other things.
Example :
<IMG SRC= "infolink.jpg" onClick
= "alert('Visit Layout Galaxy!'); return true">
<SELECT NAME= "Activity" onChange= "setLink(this.selectedIndex)">.
.
.
. </SELECT>
| Using the onSubmit Event Handler |
One of the most common uses for the onSubmit
event handler is to validate form input. You can verify that
visitors fill in required fields, make required selection,
or that they fill in an appropriate combination of fields.
Example :
Now you see an exmaple which sends an alert message to the
user saying that he has not filled in required fields.
<SCRIPT language = "JavaScript">
function checkOut( ) {
for (x=0; x<document.survey.elements.length; x++) {
if
(document.survey.elements[x].value
== " ") {
alert("Sorry,
you forgot one of the required fields. Please try again.");
break; }
}
return false;
if (document.survey.firstname.value.length <=2) {
alert("Please
enter your full first name.")
return false; }
if (document.survey.emailaddr.value.indexOf('@') == -1 ) {
alert("Please
correct your email address. It should look like you@domain.com");
return false;} }
</SCRIPT>
Copyrights : Layout Galaxy All Rights Reserved
No part of this tutorial may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, electrostatic, magnetic tape, mechanical or otherwise, without prior permission in writing from Layout Galaxy.
|
|