Use of the prompt-boxes
As we have seen, alert-boxes only gives you a message. Then, the
confirm-boxes can lead you two different pages (or directions). The
prompt-boxes on the screen
would ask you to input some information and use the
information and return something back to you (or otherwise).
Following is how
you write a javascript so that a promptbox will appear on the screen.
ExampleA: In the prompt-box that you already saw on the
screen, we asked you to
give your annual income in a prompt-box and tell you through alert-boxes
whether your income is
above or below the median-income. Here is the script:
Example: In this example we do the same, but we try to
again control using button. Unlike the later examples, we did NOT USE
functions.
ExampleB: As for alert and confirm boxes,
here we use prompt boxes with botton to gain some control.
We had to use a function to do this. The prompt-box will not
appear on the screen untill the function is called by a click
on the button.
ExampleC In this example also we use a
fuction to do the same. Only difference here is that here we prompt-box
used was the one you saw first on the screen, rest is done by the function
median(paramenter). .