File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 2409
    
    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