Continued from page 1
alert(x) creates an alert that will contain
value defined in variable x (make sure that variable x is defined before calling it)
alert("the number is " + x); -creates an alert that will combine text and
value in x.
It Can Do Math Too?
JavaScript wouldn't be much of a programming language if it couldn't do simple math. While there are dozens of complex, built-in math functions, here are
basic symbols you'll need to know:
addition + subtraction - multiplication * division / greater than > less than < greater than or equal >= less than or equal <=
What "If" Statements
"If" statements are often used to compare values. If
statement is true, a set of instructions enclosed in {} executes. Comparisons like this are done using
following symbols:
equals == not equal !=
In
example below, you can see how an "if" statement is used to determine text that displays in an alert window. Copy and paste
following script into an HTML page to see it at work.
Notice how
instructions for each statement (both
"if" and "else") are enclosed in {}(curly brackets). All curly brackets must have a beginning and ending, just like HTML tags. If a curly bracket is missing
JavaScript will return an error, so be sure to proof your code.
________________________________________ This document is provided for informational purposes only, and i-Netovation.com makes no warranties, either expressed or implied, in this document. Information in this document is subject to change without notice. The entire risk of
use or
results of
use of this document remains with
user. The example companies, organizations, products, people, and events depicted herein are fictitious. No association with any real company, organization, product, person, or event is intended or should be inferred. Complying with all applicable copyright laws is
responsibility of
user. Without limiting
rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, wit hout
express written permission of i-Netovation.com.
If you believe that any of these documents, related materials or any other i-Netovation.com content materials are being reproduced or transmitted without permission, please contact: violation@i-netovation.com.
The names of actual companies and products mentioned herein may be
trademarks of their respective owners.
