Lecture13 and 14_JavaScript3

Lecture13 and 14_JavaScript3 - Confirm Method Input method...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Confirm Method Input method but takes only Boolean. Supplies the user with a choice. Syntax: confirm ("text"); Like prompt, value returned from a confirm box has to be stored in a variable. This variable can then be used for conditional branching.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Confirm Method Used to verify something It has two buttons. OK and CANCEL. If the user clicks OK, value returned is (Boolean) true If the user clicks CANCEL, value returned is (Boolean) false
Background image of page 2
JavaScript Example 6 <html> <head> </head> <body> <script type="text/javascript"> confirm("Are your sure?"); // var a = confirm("Are your sure?"); // document.write(a); </script> </body> </html>
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A Conditional Statement: if statement Syntax if(<Boolean expression>) { <then-statement>; } <Boolean expression> -- an expression with an outcome of either true or false. <then-statement> -- one or many JavaScript statements.
Background image of page 4
Flow of Control Boolean Expression (predicate) is evaluated. If outcome of Boolean exp true <then-statement> performed false <then-statement> skipped.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JavaScript Example 7 <html> <head> </head> <body> <script type="text/javascript"> var a = 2; if (a ==2) { document.write ("a is 2"); //document.write("Value in variable a is " + a); } </script> </body> </html>
Background image of page 6
JavaScript Example 7 modified <html> <head> </head> <body> <script type="text/javascript"> var a = true; if (a == true) // if (a) { document.write ("a is true"); } </script> </body> </html>
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JavaScript Example 6 and 7 together <html> <head> </head> <body> <script type="text/javascript"> var a = confirm ("Are you sure"); if (a) { document.write ("a is true"); } </script> </body> </html>
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/15/2009 for the course CS 170 taught by Professor Ganu during the Spring '09 term at Rutgers.

Page1 / 24

Lecture13 and 14_JavaScript3 - Confirm Method Input method...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online