- Posts: 166
- Thank you received: 26
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Not a Question but a share - Multiple Other Specifies on a Multiple Choice Q
- davebostockgmail
- Topic Author
- Offline
- Elite Member
Less
More
2 years 6 days ago #227295
by davebostockgmail
Not a Question but a share - Multiple Other Specifies on a Multiple Choice Q was created by davebostockgmail
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.X
Own server or LimeSurvey hosting: Own
Survey theme/template:
==================
One of the things I have been asked to do more and more often is to have a multiple choice question which has more than one other specify answer in it ... so I thought I would share what I have done to meet this.
First of all I used a multiple choice with comments question to enable the input boxes to be shown for each answer.
Then I removed the input boxes that were not for the other specify options with a simple script (One line per box to be removed)...
$('#answer829445X923X417661comment').css("display","none");
This meant that I had the desired look of the question
Now all that was left was to ensure that if they selected any of the other specify answers the survey would not continue without the corresponding text entry in that input box (without this the respondent could check the other box and move on without answering the other part)
This was done with the following script (In this instance there were 4 other specify options needed) .....
<script>
$(document).on('ready pjax:scriptcomplete',function(){
$('#ls-button-submit').bind('click', function () {
if($("#answer829445X923X417668comment").val().length < 1 && $('#answer829445X923X417668').is(':checked')) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
if($("#answer829445X923X417669comment").val().length < 1 && $('#answer829445X923X417669').is(':checked') ) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
if($("#answer829445X923X4176610comment").val().length < 1 && $('#answer829445X923X4176610').is(':checked') ) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
if($("#answer829445X923X4176611comment").val().length < 1 && $('#answer829445X923X4176611').is(':checked') ) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
});
});
</script>
I hope this helps if someone has a similar issue ....
Your LimeSurvey version: 5.X
Own server or LimeSurvey hosting: Own
Survey theme/template:
==================
One of the things I have been asked to do more and more often is to have a multiple choice question which has more than one other specify answer in it ... so I thought I would share what I have done to meet this.
First of all I used a multiple choice with comments question to enable the input boxes to be shown for each answer.
Then I removed the input boxes that were not for the other specify options with a simple script (One line per box to be removed)...
$('#answer829445X923X417661comment').css("display","none");
This meant that I had the desired look of the question
Now all that was left was to ensure that if they selected any of the other specify answers the survey would not continue without the corresponding text entry in that input box (without this the respondent could check the other box and move on without answering the other part)
This was done with the following script (In this instance there were 4 other specify options needed) .....
<script>
$(document).on('ready pjax:scriptcomplete',function(){
$('#ls-button-submit').bind('click', function () {
if($("#answer829445X923X417668comment").val().length < 1 && $('#answer829445X923X417668').is(':checked')) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
if($("#answer829445X923X417669comment").val().length < 1 && $('#answer829445X923X417669').is(':checked') ) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
if($("#answer829445X923X4176610comment").val().length < 1 && $('#answer829445X923X4176610').is(':checked') ) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
if($("#answer829445X923X4176611comment").val().length < 1 && $('#answer829445X923X4176611').is(':checked') ) {
var moveOn = alert("You need to enter the job title in the other specify box before you can continue");
return false;
}
});
});
</script>
I hope this helps if someone has a similar issue ....
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
2 years 6 days ago #227299
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Not a Question but a share - Multiple Other Specifies on a Multiple Choice Q
It is safer to remove the inputs instead of hiding them. This will prevent people tabbing into them.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in to join the conversation.
- davebostockgmail
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 166
- Thank you received: 26
2 years 5 days ago #227303
by davebostockgmail
Replied by davebostockgmail on topic Not a Question but a share - Multiple Other Specifies on a Multiple Choice Q
Good call I have made the changes to do just that .... $('#answer829445X923X417661comment').css("display","none"); now reads $('#answer829445X923X417661comment').remove();
Thanks for the advice.
Thanks for the advice.
Please Log in to join the conversation.