adding up checkbox values
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21667
Printed Date: 28 March 2026 at 7:54am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: adding up checkbox values
Posted By: mike7510uk
Subject: adding up checkbox values
Date Posted: 20 October 2006 at 4:39pm
|
I have 4 checkboxes on a page with different values for each, if the user selects any (or all) of the boxes i want a label to display the total amount, i have got the label to display any 1 value but cant add it all up. Any ideas?
|
Replies:
Posted By: dpyers
Date Posted: 20 October 2006 at 8:01pm
Kind of depends upon if you want to use javascript to update the label in place, or if you want to make a trip back to the server.
Also depends if the check boxes are part of a group, and all have the same name, or if they each have a different name. If a group, you'd treat them like an array.
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: mike7510uk
Date Posted: 23 October 2006 at 9:05am
|
the check boxes are not part of a group. if the user checks checkbox 1 i want the label to disply a value, if the user uncecks the box, clear the value. Also, if the user checks 1 or more, add up all the value (subtracting if the box is unchecked)
|
Posted By: dpyers
Date Posted: 23 October 2006 at 9:16pm
As you're changing the display on the users machine, you'd need to use javascript. There's probably scripts available for doing something like this on the scripting sites.
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: mike7510uk
Date Posted: 24 October 2006 at 4:21pm
|
yes i got it working now, using javascript. thanks
|
|