problem with prompt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gunter
    New Member
    • May 2009
    • 1

    problem with prompt

    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

    Code:
    <HTML>
    <HEAD>
    <TITLE>Volume Discount</TITLE>
    
    <SCRIPT LANGUAGE = "JavaScript">
    
    /* A program to tell a customer what volume discount they can expect */
    
    var numberOfgiftboxes, 
    
    
    numberOfgiftboxes = window.promp
        ('Please enter how many boxes you are purchasing', type how many here, '');
    numberOfgiftboxes = parseFloat(numberOfgiftboxes);
    if (numberOfgiftboxes >= 0) & & (numberOfgiftboxes <= 3)
    {
        document.write('No Discount');
    }
    else
     
        if (numberOfgiftboxes >= 4) & & (numberOfgiftboxes <= 11)
        {
            document.write('5 % Discount');
        }
        else
        
            if (numberOfgiftboxes >= 12) & & (numberOfgiftboxes < 30)
            {
                document.write('10 % Discount');
            }
            else
            
                if (numberOfgiftboxes >= 30)
                {
                    document.write('20 % Discount');
                }
            }
        }
    }
           
    
       
    
    
    
    </SCRIPT>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>
    Last edited by acoder; May 1 '09, 02:50 PM. Reason: Added [code] tags - please use them
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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)

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      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.

      Comment

      Working...