Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
-3
rated 0 times [  4] [ 7]  / answers: 1 / hits: 16458  / 14 Years ago, mon, june 28, 2010, 12:00:00

I'm trying to add the input values of several text boxes using javascript and display the total number below. How can I add and keep the sum for displaying after the computation. I'm not an expert in javascript.


More From » text

 Answers
36

Here is an example that shows you how to do this:



<form name=myFormName>
<p><input type=text name=myInputName1 value=25.3></p>
<p><input type=text name=myInputName2 value=14.2></p>
</form>
<div id=total></div>

<script type=text/javascript>

var total = parseFloat(0, 10);

total += parseFloat(document.myFormName.myInputName1.value, 10);
total += parseFloat(document.myFormName.myInputName2.value, 10);

document.getElementById(total).innerHTML = Total is + total;

</script>

[#96392] Thursday, June 24, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hailie

Total Points: 25
Total Questions: 112
Total Answers: 111

Location: Belize
Member since Tue, Dec 8, 2020
4 Years ago
;