Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have this problem i can't seem to figure out,i'll do my best to explain it here.
 
I have a series of checkboxes each one having a name and a value and a person can choose either one or all of the boxes(it can't be radiobuttons because you can only make a single choice)
I want to know if it is possible to calculate the total amount if the person chooses any number of checkboxes from one to eight.
I.e checkbox1 value = 5
checkbox2 value = 15
checkbox3 value = 7.
etc
 
I would apprieciate any kind of help here thanks
 
============================================================
 
Below is a clarfied version of the question
 

 
Its part of a project i am trying to build.After a client chooses what car they want and how many days they want to rent it for ,you would then calculate the total amount owed for the rental.i have that part worked out,the second part is the one that i can't figure.
 
after the vehicle selection has been made the client chooses from five differant extras,these are,
 
Childseat @ 10 fixed rate
sat-nav@ 5 fixed rate
Luggage rack @ 15 fixed rate
Ski-Equiped @ 10 fixed rate

Amounts above are currency (pounds,Euros,Dollars)

Choice on the form is made via a checkbox for each item,the client can choose either one or all of the extras,my problem is how to workout how to calculate the total owing for the extras based on how many checkboxes have been choosen
 
Public class Rentalform
 
'declare module level constants

Const CHILDSEAT_EXTRA as Decimal = 10
Const SATNAV_EXTRA as decimal = 5
const LUGGAGE_RACK_EXTRA as decimal = 15
Const SKI_EQUIPED_EXTRA as decimal = 10
 

if chkChildseat.checked = true and
chkSatnav.checked = false and
chkLuggageRack.checked = false and 
chkSkiEquiped.checked = false then
 
txtTotal.text = CHILDSEAT_EXTRA 
 
If chkchildseat.checked = true and 
chkSatNav.checked = false and 
chkLuggageRack.checked = True and 
chkSkiEquiped.checked = false then
 
txtTotal.text = (CHILDSEAT_EXTRA + LUGGAGE_RACK_EXTRA )
Do i have to churn out streams of code to cover every possible choice variation i.e chilseat only,childseat and Luggagerack or maybe the client chooses all of the extras. Help please
Posted 3-Dec-12 15:08pm
Edited 4-Dec-12 12:16pm
Nelek63.5K
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You might want to use CheckBoxList[^] for this job. User can select multiple and then you can loop through the selected items and add their value to your total value.
 
Loop through ASP checkboxlist[^]
 
Good luck,
OI
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 340
1 OriginalGriff 250
2 DamithSL 170
3 Kornfeld Eliyahu Peter 130
4 Peter Leow 95
0 OriginalGriff 7,315
1 DamithSL 5,199
2 Sergey Alexandrovich Kryukov 4,917
3 Maciej Los 4,866
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100