This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how to get sum for dynamic checkboxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to get sum for dynamic checkboxes" Watch "how to get sum for dynamic checkboxes" New topic
Author

how to get sum for dynamic checkboxes

sonali duggi
Greenhorn

Joined: Oct 09, 2009
Posts: 8
hello every one.

here i have a problem in getting sum for dynamic check boxes..

my requirement is if i select one check box the amount will be added to the total amount field and select other field the total amount will display in amount field..

one thing is all check boxes are getting dynamically..

thanks in advance..
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2229
    
    7

AJAX??


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
sonali duggi
Greenhorn

Joined: Oct 09, 2009
Posts: 8
no.. i want in java script
sonali duggi
Greenhorn

Joined: Oct 09, 2009
Posts: 8
yes i got the solution

follow the below code to solve the problem

function calculate() {
var elems = document.forms['formID'].elements;
var total = 0;
for(var i=0;i<elems.length;i++) {
if (elems[i].checked) {total += +(elems[i].value);}
}
elems['total'].value = total;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get sum for dynamic checkboxes
 
Similar Threads
Show total of each column
dynamic DIV tag
Getting totals of rows in SQL
Problem with double submit
Problems with form validation