CalcBuilder Forum

Multiple option

User moon_1800 2014-09-20 12:24:07

I am having problems with the output of multiple option.
This is my code

if($question2=="option1"){
$message2="option1";

}

if($question2=="option2"){
$message2="option2";

}

else {
$message2="message2";

}

I have 3 multiple option.
If user chooses option1 only then output should be "option1"
If user chooses option2 only then output should be "option2"
If user chooses option1 and option2 then output should be "option1 option2"
if not then "message2" I cannot make this work

I also need that output"option1" has a href link. ie href=www.sample.com


Thanks a bundle

Edited by moon_1800 - 20.09.2014 13:32

Moonsoft support 2014-09-21 19:44:17

Hi,
when you use a multiple option field, the result you receive comes in form of a list of options checked. You have a php function able to find out if a value is present at that result. Assuming your field is named 'question2', and you have the optional values 'option1', 'option2', and 'option3', you can use.

$message="Default message in case none of the conditions below is met.";

if(in_array("option1",$question2)){

$message="This means option1 was selected";

}

if(in_array("option3",$question2)){

$message="This means option3 was selected";

}

if(in_array("option1",$question2)&&in_array("option2",$question2)){

$message="This means option1 AND option2 were selected";

}



etc.

you can output any html inside the result, something like

$message="LINK";

(replace the signs for the proper tags, the forum strips the less than lower than chars)

will print a link to our site at the output.

Hope this helps, regards

Edited by MSTeam - 21.09.2014 19:45

...
CalcBuilder

Create dynamic calculators

Buy now!
...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!