Hello, I think I’ve mastered using logic in scripts with radio buttons answers, but I just cannot figure how to do it with Checkboxes.
So, I have a radio button question and I can write….
if (sgapiGetValue(%%radiobuttonquestion) == “blahblah” )
But what is the equivalent with Checkboxes? I would like something that says “if they tick this box then do that” but after three or four hours I still can’t get it. It probably has something to do with In_Array and sgapiPrint_R(sgapiGetValue(xxx)), but all I can do is extract the entire array
Array(  => blahblah)
What I really want to write is something like
if ((sgapiGetValue(%%thecheckboxquestion, option row 3) == “blahblah”)
I’ve sorted this now, many thanks to those who looked in….
The first step is to get the array, this is done with sgapiGetValue, in my case:
which returns an array from Question ID 5, which in my case is
Array(  => run  => jump)
The second step is to extract the reporting value within the array you want access to, which in my case was the word “jump”
The function here is called sgapiArrayGet
This has a syntax as follows:
sgapiArrayGet(an array, the id of the option you want)
It has an output value of the reporting value of just that id option.
Putting the two bits together you get
which returns the word “jump”
I then used that result in a conditional statement: if the checkbox says jump then you say “how high”
Hi, I appreciate your reaching out, but I’m fraid it is not really working for me…
If I put in..
I get a blank response (id=96 is a checkbox)
So I add the sgapiPrint command as advised:
and I get a response, albeit packed inside an array:
Array(  => prefer others)
But when when I try to add options…
I get Bad Syntax, like the (questionid, option(id)) syntax is wrong.
Driving me crazy!
You need to find the option ids. There is some help with that here:
Then your if statement will look something like:
if ((sgapiGetValue(%%thecheckboxquestion, option(nnnnn) == “xxx”)
Where nnnnn is the option ID and xxx is the reporting value for that checkbox.