Jump to content

Recommended Posts

hi,

 

i'm new with programming and i am supposed to create a simple calculator. i already have generated a script but i don't know how will i add case switch on it. you may refer to my code below:

<html>

    <head>

          <title> Sample Calculator </title>

    </head>

    <body>

           

<form method="post" action="calculator.asp">

          <table border="0">

          <tr>

                <td>Value 1: </td>

                <td><input type="text" name="value1"</td>     

          </tr>

          <tr>

                <td>Value 2: </td>

                <td><input type="text" name="value2"</td>

 

            </tr>

            <tr>

                <td>Operation: </td>

                <td><select>

                              <option value="add">+</option>

                              <option value="subtract">-</option>     

                              <option value ="divide">/</option>

                              <option value="multiply">*</option>

                </select>

                </td>   

            </tr>

            <tr>

            <td><input type ="submit" value="Submit" name="Submit Answer"></td>

   

            </tr>

              <tr>

                <td>Answer: </td>

                <td><input type="text"  name="answer">

                </td>   

            </tr>

 

        </form>

 

     

 

    </body>

</html>

 

can someone help me on how to add case switch or if-else statement in my code?

 

thanks in advance!  ::)

Link to comment
https://forums.phpfreaks.com/topic/234653-how-to-add-switch-javascript/
Share on other sites

Is that a school assignment or something? To create a calculator, first you need to catch events and get input and select values. After that you'll need to make the logic. Take a look at jQuery, a Javascript framework that will help a lot in selectors and dom manipulation (and much more actually).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.