Welcome, Guest
Username: Password: Remember me

TOPIC: Enable disable answer option

Enable disable answer option 8 months 1 day ago #102762

  • darpao
  • darpao's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
How can I disable radio button based on a previous question answer?

For example:

A - Insert a number (1 or 2)

B - Choice one
10 -> enabled if 1 or 2 at A
11 -> enabled if 1 at A
12 -> enabled if 2 at A
13 -> enabled if 1 or 2 at A
The administrator has disabled public write access.

Enable disable answer option 8 months 4 hours ago #102776

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4119
  • Thank you received: 760
  • Karma: 346
There is no built-in capability to apply conditions or relevance to answers, however, you could create two versions of question "B" and use conditions or relevance to show the appropriate version.

Another approach would be to use JavaScript to filter the answers in question "B" but this would only really work if both questions are on the same page.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Enable disable answer option 8 months 43 minutes ago #102799

  • darpao
  • darpao's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
I would like to use Javascript, but I'm not able to find a sample script easy to change..

The first one is not possible because the options are not 2 but more.. so I should use too many versions of second question..

I'm surprised there isn't something like this!!

Anyway, thank you.. I will investigate more..

Actually I use this script, but is not easy to use..
Every time I have to change everything if I copy the survey from a server to another.. but I cannot understand all this calls to questions in LimeSurvey..

For example.
This works for radio button, but for checkbox?!?

Why sometime #question355 is good and other times I need to use #answer364448X11X3551 ?!?

Where I can find all methods that I can apply to a question and its documentation? Like

$("#question354 input").change(function() { ........... });
$("#question355 input").each(function() { ........... });

Or a list of attributes like:
$("#question355 input:radio").attr("checked", false);
$(this).attr("disabled",false);



<script type="text/javascript" charset="utf-8">
function checkGeo() {
var D9 = $("#question354 input:checked").val();
var D10 = [ "#answer364448X11X3551","#answer364448X11X3552","#answer364448X11X3553",
"#answer364448X11X3554","#answer364448X11X3555",
"#answer364448X11X3556","#answer364448X11X3557","#answer364448X11X3558" ];

if (D9 == "9" || D9 == "10") {
for (var i=0; i<=5; i++) {
$(D10).attr("disabled",true);
}

$(D10[7]).attr("disabled",true);

var answer = $("#answer364448X11X3557");
answer.click();
answer.attr("checked", true);

}

else if (D9 != "7" && D9 != "8" && D9 != "11" && D9 != "5") {
$("#answer364448X11X3556").attr("disabled",true);
$("#answer364448X11X3557").attr("disabled",true);
}


}
$(document).ready(function() {
$("#question354 input").change(function() {
// nel caso in cui cambiando la risposta precedente deve essere disabilitato un input già selezionato
$("#question355 input:radio").attr("checked", false);
$("#question355 input").each(function() {
$(this).attr("disabled",false);
});

checkGeo();
});
});
</script>
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.128 seconds
Donation Image