how to:

G

Guest

hey all,

i have two textboxes on a webform that are inputs for numbers.
using client-side script (any language) how would i add the values together
and put in another textbox or variable?

thanks,
rodchar
 
G

Guest

var input1 = document.getElementById("input1");
var input2 = document.getElementById("input2");
var total = document.getElementById("input3");
//this is a regular expression to verify the inputs are real number
if (/^(\+|-)?\d+(\.\d+)?$/.test(input1.value) &&
/^(\+|-)?\d+(\.\d+)?$/.test(input2.value) )
{
total.value=parseFloat(input1.value)+parseFloat(input2.value);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

display running total using all client side code 3
client side 2
how to: please 2
validation 2
is this possible 6
client and server 3
what am i doing wrong? 8
javascript values to array 4

Top