www.webdeveloper.com
Results 1 to 2 of 2

Thread: Syntax help

  1. #1
    Join Date
    May 2011
    Posts
    24

    Syntax help

    i know there is no brackets in this program that is because i am not sure where to put them the program is set to calculate from the prompt how many cars sold what the commision and bonuses are
    the code is as follows:

    <html>
    <head>
    <script type="text/javascript">
    function show_prompt(){
    var carnum=prompt("how many cars have you sold");
    var commision = (carnum * 100)
    var bonus =((carnum - (carnum % 15) / 15)) *150
    document.write("You Sold " + carnum + 'cars')
    <br>
    document.write( 'your comission is:' + commision + '<br/>');
    <br>
    document.write( 'Your bonus is:' + bonus + '<br/>');
    </script>
    <body onload = "show_prompt()">
    </head>
    </html>

    the code is solid but im not sure where i have went wrong please help

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function show_prompt(){
    var carnum=Number(prompt("how many cars have you sold"));
    var commision = (carnum * 100);
    var bonus =((carnum - (carnum &#37; 15) / 15)) *150;
    var div=document.getElementById('mydiv');
    var txt="You Sold " + carnum + "cars <br><br>";
    txt+="Your comission is:&#163;" + commision+"<br><br>";
    txt+="Your bonus is:&#163;" + bonus;
    div.innerHTML=txt;
    }
    onload=function(){
    show_prompt();
    }
    </script>
    </head>
    <body>
    <div id="mydiv50"></div>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles