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 > Flow Control

  Flow Control

If and if ....else
Looping statement
Switch statement
Break statement
Continue statement

  If and if ....else

If Statement
If...else Statement

  If Statement

The first instruction that enables you to control the flow is called the "if" statement. Basically, it enables you to perform tests inside program code to determine which parts of the program should be run under any given situation.

Syntax :

If ( Condition ) {
            Statement ……
}

Example :

If ( form.marital.Value == "Married" ) {
           document.write("Mrs." );
}
If ( form.marital.Value == "Unmarried" ) {
             document.write("Miss." );
}

  If...else Statement

You can also write the preceding example in a slightly different way, by using a different version of the "if" Statement that incorporates an else statement.

Syntax :

If ( condition) {
             (Statement….. ) }
else {
             (Statement….. ) }

Example :

If ( form.marital.Value == "Married" ) {
              document.write("Mrs." );
}
else {
              document.write( "Miss.");
}

  IF Statement

Assume that you have a web form that asks whether a person is male or female. If the property bas.n.value had been assigned a value of "male", the first document.write( ) method would have been called. If it had been assined a value of "female", the second statement would have been displayed.

Here the bas is the current form and n is the name of the field as a subobject of the form bas.

Type male or female in the first text field and Click the button "Click Me" to view the result in the second text field.

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