dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: help with function and switch program

  1. #1
    Join Date
    Jan 2013
    Posts
    4

    help with function and switch program

    i am sure i am doing something wrong but can't figure out what

    HTML Code:
    <script>
    function sum()
    var num1=parseInt(prompt("please enter 1st no"));
    var num2=parseInt(prompt("please enter 2nd no"));
    var sum=num1+num2;
    {
    document.write("sum is"+sum);
    }
    function subs(num1,num2)
    var sub1=num1-num2;
    {
    document.write("sub is"+subs);
    }
    var opt=parseInt(prompt("do you want sum or subs"));
    switch(opt)
    {
    case1:
     sum();
    break;
    case2:
     subs();
    break;
    default:
    document.write("hg")
    }
    </script>
    </body>
    </html>

  2. #2
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    Read up on functions and switch/case at these links.

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    space after case

  4. #4
    Join Date
    Jan 2013
    Posts
    4
    can anyone just tell me what i am doing wrong in above code

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