|
|
If and if ....else |
|
|
Looping statement |
|
|
Switch statement |
|
|
Break statement |
|
|
Continue statement |
|
|
If Statement |
|
|
If...else 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." ); }
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."); }
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.

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.
|
|
|