CalcBuilder Forum

YES/NO (checkBOX) - VALUE number

Usuario moon_1309 2013-12-04 21:39:58

Hello.

My calculator consists of sets "multiple->YES/NO".
payment must occur by summing the checkboxes (YES/NO) field
($result=#checkbox1+checkbox2+....checkboxN)

But the FIELD, (YES/NO - type), has no option where you can enter a value.

How can I set the "number" of the "field"?
(Option list)
Multivalues
Actions: Add Delete All-------------------------Name_______Value_____
SQL Actions: Add Del
CSV Actions: Add

Moonsoft support 2013-12-05 09:39:04

Hi,
checkboxes have value "Y" when selected, that you can use to confirm if user checked or not the option, but you can give them a numeric value at the code, you don't need to overwritte the default value of the check. Here a couple of examples:

Field: check0- typed YES/NO
Field: check1- typed YES/NO


//at the code, we'll create values for each check, but we give them different name:

$check0value=5;
$check1value=8;

//if you want to calculate the sum of the two options, regardeless of whether are selected or not:

$result=$check0value+$check1value;


//and now, if you want to sum ONLY the selected values:

$result=0;

//if check0 is selected, add its value to result
if($check0=="Y"){
$result=$result+$check0value;

}



//if check1 is selected, add its value to result
if($check1=="Y"){
$result=$result+$check1value;

}

//you will get at $result the sum of the options


Hope this helps, regards

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
List Manager

Build different lists for your site

Buy now!