复选框问题,计算所做选择的总和 [英] Checkbox problem,calculating the sum total of choices made

查看:108
本文介绍了复选框问题,计算所做选择的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题我似乎无法弄清楚,我会尽力在这里解释一下。



我有一系列的复选框每个都有一个名称和一个值,一个人可以选择一个或所有的盒子(它不能是radiobuttons因为你只能做一个选择)

我想知道如果有人可以选择从1到8的任意数量的复选框,则可以计算总金额。

即复选框1值= 5

checkbox2 value = 15
checkbox3 value = 7.





我会在这里给予任何帮助,谢谢



======================================== ====================



以下是问题的澄清版本







这是我正在努力建设的项目的一部分。在客户选择他们想要的汽车以及他们需要多少天之后想要租用它,你会计算总数租金的欠款。我有这个部分,第二部分是我无法想象的。



选择车辆后客户从五个不同的额外内容中选择,这些是,


Childseat @ 10固定费率

sat-n​​av @ 5固定费率

行李架@15固定价格

滑雪套装@ 10固定价格



以上金额为货币(英镑,欧元) ,美元)



表格上的选项是通过每个项目的复选框,客户可以选择一个或所有额外的,我的问题是如何锻炼如何根据已选择的复选框计算额外费用的总金额



 公开  Rentalform 

' 声明模块级别常量

Const CHILDSEAT_EXTRA as 十进制 = 10
Const SATNAV_EXTRA as 十进制 = 5
const LUGGAGE_RACK_EXTRA as decimal = 15
Const SKI_EQUIPED_EXTRA as decimal = 10


如果 chkChildseat.checked = true < span class =code-keyword>和
chkSatnav.checked = false
chkLuggageRack.checked = f alse
chkSkiEquiped.checked = false 然后

txtTotal.text = CHILDSEAT_EXTRA

如果 chkchildseat.checked = true
chkSatNav.checked = false
chkLuggageRack.checked = True
chkSkiEquiped.checked = false 然后

txtTotal.text =(CHILDSEAT_EXTRA + LUGGAGE_RACK_EXTRA)



我是否需要生成代码流以涵盖所有可能的选择变化,例如chilseat,childseat和Luggagerack或者客户端选择所有额外的东西。请帮助

解决方案

您可能想要使用 CheckBoxList [ ^ ]这项工作。用户可以选择多个,然后您可以遍历所选项目并将其值添加到您的总价值。



循环ASP复选框列表 [ ^ ]



祝你好运,

OI

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

解决方案

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


这篇关于复选框问题,计算所做选择的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆