Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Show Text based on constructed list

Hi,

I am trying to post a specific text based on a value of a constructed list. The constructed list is empty,

1.
2.
3.
4.

we use it to randomly show one of 4 pages.

Now I am trying to post a text on the next page based on the list member that was drawn. I tried the following script:

<style type="text/css">
[% Begin Unverified Perl

if(GETVALUE("randlist1_1") == 1)

{

 return "1";

}

elsif(GETVALUE("randlist1_1") == 2)

{

 return "2";

}

elsif(GETVALUE("randlist1_1") == 3)

{

 return "3";

}

else(GETVALUE("randlist1_1") == 4)

{

 return "4";

}

End Unverified %]
</style>

Unfortunately it is not working. I also tried to switch the variable from "randlist1_1" to "sys_block_set_1". Both is not working.

I also tried the script with a hidden variable
<input name="priceDisplay" type="hidden" value="[%randlist1_1%]">

And then used priceDisplay in the Script.

I have looked through the following link:
https://sawtoothsoftware.com/help/lighthouse-studio/manual/unverfiedperl.html#examples

Unfortunately, I did not find the solution. It would be great if someone can help me out.

Thanks
Joshua
asked Dec 13, 2021 by JoshuaS (250 points)

1 Answer

0 votes
Instead of GETVALUE try LISTVALUE.  The getvalue is for the response to a question or variable where listvalue calls up the member position you indicate in your list and will return the value of the parent list for that item.
answered Dec 13, 2021 by Jay Rutherford Gold (49,130 points)
Joshua, if you want to display the first item of what was selected in your constructed list, then yes, that is the list you should be referencing.  It will show the label or value from the parent list of whatever that first item in your constructed list is.
Thanks a lot for the reply. I actually want to display a text and not the value.

So what I have the following predefined list (list4):

1.
2.
3.
4.

I have a constructed list (randlist1) with list4 as a parent list:  
ADD(list4)
Randomize()
SetListLength(1)

I use this constructed list for the randomized blocks: only one of 4 pages is shown.
Based on the page which is shown, I want to display different text versions thats why I was trying to use the return function.
However, nothing is really working out.

Thanks a lot in advance
If you do what Zach suggested and in list4 give each item the text you are looking to show.  Your constructed list remains as is.  Use [% Listlabel (randlist1,1) %] where you want that text to show up.  Is this what you have tried?  Perhaps I'm not understanding.
Perfect, it is working now. Thanks a lot for the help. I used the predefined list instead of the constructed list, sorry for the confusion. Appreciate your help guys :-)
Glad you got it working as needed!  List work can be confusing at first, but a very powerful tool to accomplish a lot of things.
...