Have an idea?

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

3 questions - Question is visible and shorten the codes

Hi,

I am in need of clarifications for the below 3 questions.

Question: 1

I have a hidden question the only question in a page and it should not be visible while answering the survey. I have added the below code but still it is visible

<style>
#[% QuestionName() %]_div {
    display: none;
}
</style> 


Question: 2

I want to find whether value 12 is available or not in the constructed list, the below code works fine but it seems to be lengthy.

<input name="[% QuestionName() %]_Sports" id="[% QuestionName() %]_Sports" type="hidden" value="
[% Begin Unverified Perl
if (LISTVALUE("Attributes3",1)==12) {return 1;}
elsif (LISTVALUE("Attributes3",2)==12) {return 1;}
elsif (LISTVALUE("Attributes3",3)==12) {return 1;}
......................
......................
......................
elsif (LISTVALUE("Attributes3",85)==12) {return 1;}
else {return 0;}
End Unverified %]
 ">


Is there any other method to use instead of above lengthy and below loop codings?

<input name="[% QuestionName() %]_Sports" id="[% QuestionName() %]_Sports" type="hidden" value="
[% Begin Unverified Perl
my $a=0;
for( $a = 1; $a <= 85; $a = $a + 1 ){
if (LISTVALUE("Attributes3",$a)==12) 
{
return 1;
last;
}
}
return 0;
End Unverified %]
">



Question: 3

I want to show different level texts for screener against other ACBC sections and use the following code

if(QUESTIONNAME() eq "Beverages_Unacceptable1" || QUESTIONNAME() eq "Beverages_Unacceptable2" || QUESTIONNAME() eq "Beverages_Unacceptable3" || QUESTIONNAME() eq "Beverages_Unacceptable4" || QUESTIONNAME() eq "Beverages_MustHave1" || QUESTIONNAME() eq "Beverages_MustHave2" || QUESTIONNAME() eq "Beverages_MustHave3" || QUESTIONNAME() eq "Beverages_MustHave4" || QUESTIONNAME() eq "Beverages_MustHave5")
{
return "Without Caffeine";
}


Instead of this, is there any way to use like below?

if(QUESTIONNAME() eq Unacceptable || QUESTIONNAME() eq MustHave)


Please help. Thanks
asked Oct 5 by Abdul Bronze (1,540 points)
retagged Oct 5 by Walter Williams
Here's something that can help with Question 2.
Instead of using LISTVALUE, use the following ...
LISTHASPARENTMEMBER("Attributes3",12)

Here's something that can help with Question 3.
Begin Unverified Perl
 
 my $i=1;
 my $textdisplay="";
 
 for($i=1; $i<=5 $i++)
  {
   if ((QUESTIONNAME() eq "Beverages_Unacceptable".$i) || (QUESTIONNAME() eq "Beverages_MustHave".$i))
    {  
     $textdisplay="Without Caffeine";
    }  
  }

return $textdisplay;

End Unverified
I have used the following to hide free format hidden questions ...
<style>
.freeformat
{
 display:none;
}
</style>

I'm not the expert here but does this help?
Hi Paul,

Your solution works for my 2nd question but not for 1st one. I will try for the 3rd question's solution and let you know.

Thanks you so much!
I wasn't 100% clear on your q1.
I will inform Zachary as he is the expert with CSS.
With regards to question 1, your code looks fine.  Can you tell me where you've placed the code?  It ought to work in a location like the question's footer or the question's HTML head tag, but not somewhere like the survey's header, footer, or HTML head tag.

Your answer

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...