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

problem with prompt

P: 1
I would be grateful if someone could please point out where i have went wrong in the following script. Before i wrote code windows prompted for a number of boxes, now nothing appears, but i cannot figure out where i have went wrong.

thankyou very much

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE>Volume Discount</TITLE>
  4.  
  5. <SCRIPT LANGUAGE = "JavaScript">
  6.  
  7. /* A program to tell a customer what volume discount they can expect */
  8.  
  9. var numberOfgiftboxes, 
  10.  
  11.  
  12. numberOfgiftboxes = window.promp
  13.     ('Please enter how many boxes you are purchasing', type how many here, '');
  14. numberOfgiftboxes = parseFloat(numberOfgiftboxes);
  15. if (numberOfgiftboxes >= 0) & & (numberOfgiftboxes <= 3)
  16. {
  17.     document.write('No Discount');
  18. }
  19. else
  20.  
  21.     if (numberOfgiftboxes >= 4) & & (numberOfgiftboxes <= 11)
  22.     {
  23.         document.write('5 % Discount');
  24.     }
  25.     else
  26.  
  27.         if (numberOfgiftboxes >= 12) & & (numberOfgiftboxes < 30)
  28.         {
  29.             document.write('10 % Discount');
  30.         }
  31.         else
  32.  
  33.             if (numberOfgiftboxes >= 30)
  34.             {
  35.                 document.write('20 % Discount');
  36.             }
  37.         }
  38.     }
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. </SCRIPT>
  47. </HEAD>
  48. <BODY>
  49. </BODY>
  50. </HTML>
May 1 '09 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
This is a Javascript question, not a Java question; the two languages don't have much in common. I move this thread to the correct forum.

kind regards,

Jos (moderator)
May 1 '09 #2

acoder
Expert Mod 15k+
P: 16,027
Look at your error console (in a decent browser). It will highlight the errors with error messages and line numbers.

There are a number of problems. Two immediate ones are: on line 9, you need to end the statement with a semi-colon; and on line 12, it's window.prompt, not promp.
May 1 '09 #3

Post your reply

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