13Programming Structure VX

13Programming Structure VX - Input Data from User Some...

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

View Full Document Right Arrow Icon
(1) Obtain user input with prompt dialog a prompt dialog: allows the user to type a value. Some common methods to input data from user: var who, wanted_color; who=prompt( ‘ Who? , ‘ ’ ); wanted_color=prompt( ‘ Which color? , ‘ ’ ); Which color? red Who? John who wanted_color (2) Okay / Cancel: Using confirm dialog if ( confirm( "Do you want to make it bold?" ) ) document.write('Dear <b><span style="color:'  + wanted_color  + '">'  + who  + '</span></b>,' ); else   document.write('Dear <span style="color:'  + wanted_color  + '">'  + who  + '</span>,' ); confirm dialog Asks for OK / Cancel. if (. .) . . else . . Checks the true/false value returned by the confirm dialog and performs the corresponding action. Input Data from User Use + to com bine lines 12-19 in slide 4
Background image of page 1

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

View Full DocumentRight Arrow Icon
(2) cont’d Okay / Cancel: Using confirm dialog <html> <head> <title>Demo</title> </head> <body> <script type="text/javascript"> var who, wanted_color; who=prompt( ‘ Who? , ‘ ’ ); wanted_color=prompt( ‘ Which color? , ‘ ’ );
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/10/2012 for the course CS 1301 taught by Professor Dr.wong during the Winter '08 term at City University of Hong Kong.

Page1 / 6

13Programming Structure VX - Input Data from User Some...

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

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