LimeSurvey Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Hiding a checkbox in a multiple-opt question type
(0 viewing) 
Go to bottom
TOPIC: Hiding a checkbox in a multiple-opt question type
#37509
dfewl
Fresh Lemon
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Hiding a checkbox in a multiple-opt question type 1 Month, 1 Week ago Karma: 0
I saw the code on how to hide the comment box in multiple-opt with comments question types, but can somebody tell me how to hide a particular option in a regular multiple-opt question type?
 
Logged Logged
  The administrator has disabled public write access.
#37523
tpartner
LimeSurvey Team
Posts: 625
graphgraph
User Offline Click here to see the profile of this user
Re:Hiding a checkbox in a multiple-opt question type 1 Month, 1 Week ago Karma: 19
Set up your survey to use JavaScript and place the following in the source of the multi-options question. Replace "QQ" with the multi-options question ID and "NN" with the option number you want to hide.
Code:

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

function hideOption(qID, optNum) {
var index = optNum - 1;
$('#question' + qID + ' td.answer li:eq(' + index + ')').hide();
}

hideOption(QQ, NN)
});

</script>

 
Logged Logged
 
Cheers,
Tony
  The administrator has disabled public write access.
#37534
Mazi
Moderator Lime
Posts: 5284
graph
User Offline Click here to see the profile of this user
Re:Hiding a checkbox in a multiple-opt question type 1 Month, 1 Week ago Karma: 76
Tony,
can this also be done by a line of CSS in template.css? Might be an easier solution than using JS?!
 
Logged Logged
 
Best regards,
Mazi
______________________
Need help? I can: set up Limesurvey for you / create your survey / implement additional features / design your template / offer premium support --> Contact
  The administrator has disabled public write access.
#37554
tpartner
LimeSurvey Team
Posts: 625
graphgraph
User Offline Click here to see the profile of this user
Re:Hiding a checkbox in a multiple-opt question type 1 Month, 1 Week ago Karma: 19
Yes, you could do it with CSS - each list item has a unique ID. However I just assumed that dfewl was looking for the capability of dynamically hiding an option. That is, if something happens, then hide the option.

So the code would really be something like:
Code:

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

function hideOption(qID, optNum) {
var index = optNum - 1;
$('#question' + qID + ' td.answer li:eq(' + index + ')').hide();
}

if (somecondition) {
hideOption(QQ, NN);
}
});

</script>

 
Logged Logged
 
Cheers,
Tony
  The administrator has disabled public write access.
#37637
dfewl
Fresh Lemon
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:Hiding a checkbox in a multiple-opt question type 1 Month ago Karma: 0
Thanks everybody for your responses. This worked great for what I needed, and the re-usability of this code is a nice bonus. I'm beginning to have a better understanding of the different CSS elements.
 
Logged Logged
  The administrator has disabled public write access.
#37643
tpartner
LimeSurvey Team
Posts: 625
graphgraph
User Offline Click here to see the profile of this user
Re:Hiding a checkbox in a multiple-opt question type 1 Month ago Karma: 19
You're welcome.
 
Logged Logged
 
Cheers,
Tony
  The administrator has disabled public write access.
#37646
Mazi
Moderator Lime
Posts: 5284
graph
User Offline Click here to see the profile of this user
Re:Hiding a checkbox in a multiple-opt question type 1 Month ago Karma: 76
You're welcome! If our hints have been helpful and you enjoy limesurvey please consider a donation to the team . We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.
 
Logged Logged
 
Best regards,
Mazi
______________________
Need help? I can: set up Limesurvey for you / create your survey / implement additional features / design your template / offer premium support --> Contact
  The administrator has disabled public write access.
Go to top
Donation Image