iamcat Posted April 25, 2011 Share Posted April 25, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/234653-how-to-add-switch-javascript/ Share on other sites More sharing options...
trq Posted April 25, 2011 Share Posted April 25, 2011 can someone help me on how to add case switch or if-else statement in my code? Considering there is no programming logic available within simple markup languages like HTML your going to need to be allot more specific in your question. Quote Link to comment https://forums.phpfreaks.com/topic/234653-how-to-add-switch-javascript/#findComment-1205856 Share on other sites More sharing options...
Fadion Posted April 25, 2011 Share Posted April 25, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/234653-how-to-add-switch-javascript/#findComment-1205889 Share on other sites More sharing options...
Maq Posted April 25, 2011 Share Posted April 25, 2011 1) In the future, please use tags around your code. 2) This is a JS question, not PHP. Quote Link to comment https://forums.phpfreaks.com/topic/234653-how-to-add-switch-javascript/#findComment-1205910 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.