Untitled Document



 Introduction to HTML
 Structure of HTML
 Creating First HTML  Document
 Building Your HTML  Document
 Tables
 Frames
 Including Images into  Document
 Including Multimedia
 Developing HTML  FORMS
 Using Style Sheet
 Understanding URLs
 Using JavaScript
 Introducing JavaScript
   Using JavaScript
 Introducing to  JavaScript
   What is JavaScript?
 Why should you use  Java Script?
 Structure of a  JavaScript
   Syntax of JavaScript
 JavaScript
 Statements
 
 Statements
 Blocks
 
 Blocks
 Comments
 
   Comments
 Single-Line  Comments
 Multiline Comments
 Data
 
   Data
   Strings
   Numbers
   Boolean
 Null
 Expressions
 
   Expressions
   Numeric Expressions
 Logical Expressions
 Variables
 
   Variables
 Defining and Naming  Variables
 Changing the Value  of a Variable
 Functions
 
   Functions
   Built-in Functions
 User-Defined  Functions
 Returning Values  from Function
 Flow Control
 
   Flow Control
   If and if ....else
   If Statement
   If...else Statement
   IF Statement
   Looping Statements
   For Loops
   While Loops
   WHILE Statement
   Switch Statement
   Break Statement
 Continue Statement
 Objects
 
   Objects
   Methods
   Properties
   Built-in Objects
 User-defined Objects
 Arrays
 
 Arrays
 Event Handlers
 
   Event Handlers
 onMouseOver,  onMouseOut Events
 onClick, onChange  Events Handlers
 Using the onSubmit  Event Handler
 Introduction to Cookies
 
 Introduction to  Cookies
   Sessions Cookies
 Persistent Cookies
 Using Java

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.




  Using JavaScript > Event Handlers

  Event Handlers

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 :

  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 :

  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>

Back Next


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.




17, Vadsarvala Nivas, 65-A, J. Nehru Road, Mulund (W), Mumbai - 400 080 INDIA
Tel : 91-22-25795588, 91-22-25780444 Fax : 91-22-25793397
Email : ionline@vsnl.com
© Image Online 2001-2003