![]() |
Hi need help with this code. javascript
This is my code i dont get it to work, i want it to ask the user how is he and depending on the answer alert something, and call the user by the name.
<HTML> <body> <script type="text/javascript"> var name=prompt("Hi. Whats your name?") var mood=prompt("Hi " + name + ". How are you?") var fine="fine" var bad="bad" if mood==fine alert("Im glad you are fine, " + name) if mood=bad alert("Ooo. Thats bad, Im sorry. I hope you get better, " + name) </body> </SCRIPT> </HTML> |
error console
|
This may help. You can compare the code and the comments to your original code.
Code:
<HTML> |
Quote:
|
http://javascriptexample.net/inc/prompt.gif
What do you expect to happen when your visitor checks the checkbox to turn off JavaScript (as you can see appears in some browsers as shown above - since prompt is intended for debugging use only)? If that is selected then no value gets returned from the prompt. You'd do better to use a form in the web page if you want visitors to be able to enter something. |
| All times are GMT +1. The time now is 06:24 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.