- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Enable disable answer option
- darpao
- Topic Author
- Offline
- New Member
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
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10108
- Thank you received: 3593
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.
- darpao
- Topic Author
- Offline
- New Member
- Posts: 13
- Thank you received: 0
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>