SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: calculator

  1. #1
    SitePoint Member
    Join Date
    May 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    calculator

    is there a way to make a calculator? I am trying but its not working...
    <html>
    <head>
    <script language="JavaScript">
    var Num1 = prompt("Number");
    var Opt = prompt("Operation");
    var Num2 = prompt("Number");
    var Answer = ""
    </script>
    </head>
    <body>
    <script language="JavaScript">
    if (Opt=="*"){
    Answer = Num1 * Num2}
    elseif (Opt=="/"){
    Answer = Num1 / Num2}
    elseif (Opt=="+"){
    Answer = Num1 + Num2}
    elseif (Opt=="-"){
    Answer = Num1 - Num2}
    alert(Num1+" "+Opt+" "+Num2+" = "+Answer)}
    </script>
    </body>
    </html>

  2. #2
    _ silver trophy ses5909's Avatar
    Join Date
    Jul 2003
    Location
    NoVa
    Posts
    5,466
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Sara


Bookmarks

Posting Permissions

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