By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

Why won't windows.alert work?

100+
P: 103
I am learning javascript with help of tutorials and have typed this simple code.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <title>Windows and Window Properties</title>
  4.  
  5. <script language ="javascript">
  6. Response ="";
  7. while((Response=="")||(Response =="<undefined>")){
  8.     Response=window.prompt("Please Enter your Name");
  9. }
  10. if(response == "undefined")
  11.     {
  12.     window.alert("Hello, Welcome to our page!");
  13.     }
  14. else 
  15. {
  16.     window.alert("Hello, " + Response + "! Welcome to our page!");
  17. }
  18. document.write("<br> THis is the content of the window.html page: <br>")
  19. </script>
  20.  
  21. </body>
  22. </html>
When I run the page in Chrome, IE, and Firefox the window.prompt works as should. The rest of the code fails. It should alert me either of the two alerts depending if the user enter a name, but it does nothing nor does it do the document.write. Any suggestions or answers would be greatly appreciated.
Jan 6 '12 #1

✓ answered by drhowarddrfine

'Response' is not the same as 'response'. I'm sure there is also an issue with 'undefined' and how you equate it but I'm on the run.

Share this Question
Share on Google+
3 Replies


drhowarddrfine
Expert 5K+
P: 7,435
'Response' is not the same as 'response'. I'm sure there is also an issue with 'undefined' and how you equate it but I'm on the run.
Jan 6 '12 #2

100+
P: 103
Thanks for the oversight on Response, I fixed that. But still no luck on moving forward.
Jan 6 '12 #3

100+
P: 103
You were correct. It was just some formatting errors.
Jan 7 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.