INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a Computer / IT professional? Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Feedback
"...Your site has saved me hours of work that I cannot begin to express my satisfaction..."
Geography
Where in the world do Tek-Tips members come from?
|
Add numeric values together
|
How do I add numeric values dynamically without hitting the 'Submit' button? (version 1)
Posted: 11 May 07 (Edited 11 May 07)
|
<script language="javascript" type="text/javascript"> function addd() { document.addem.input1.value= "" document.addem.input2.value= "" }
function addthem() { //FIRST INPUT VALUE var add1 = document.addem.input1.value var add1 = parseFloat(add1, 10) add1 = (isNaN(add1))?0:add1;
//SECOND INPUT VALUE var add2 = document.addem.input2.value var add2 = parseFloat(add2, 10) add2 = (isNaN(add2))?0:add2; //ADD THEM TOGETHER return eval(add1) + eval(add2); }
function addition() { document.addem.answer.value = addthem() } // --> </script>
<form name="addem"> <table border="0" cellpadding="2"> <tr><td colspan="3"><p>Enter any number. Numbers get added up upon every move. Fields can be left blank!!</p></td></tr> <tr> <td>add: <input type="TEXT" name="input1" onChange="addition(addem)" size="20" maxlength="10"></td> <td>add: <input type="TEXT" name="input2" onChange="addition(addem)" size="20" maxlength="10"></td> <td>answer: <input type="TEXT" name="answer" onFocus="this.blur();" size="20" maxlength="10"></td> </tr> </table> </form>
|
Back to Javascript FAQ Index
Back to Javascript Forum |
|
 |
|
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close