- Posts: 19
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
put the other´s textbox in a X Axis
- miguelvillegas88
- Topic Author
- Offline
- New Member
Less
More
6 years 4 months ago #159945
by miguelvillegas88
put the other´s textbox in a X Axis was created by miguelvillegas88
HI, Im sorry can you help me, i want to put the other´s textbox in a X Axis, like the image
this is the script
thanks
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var thisQuestion = $('#question'+{QID}+'');
var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)');
var nextQuestion2 = $(thisQuestion).nextAll('.text-short:eq(1)');
var nextQuestion3 = $(thisQuestion).nextAll('.text-short:eq(2)');
var nextQuestions = $(nextQuestion1).add(nextQuestion2).add(nextQuestion3);
var nextLength = nextQuestions.length;
var sqLength = ('tr.answers-list', thisQuestion).length;
// Hide the short-text question
$(nextQuestions).hide();
// Move the hidden text inputs into the array
for (i = 0; i < nextLength; i++) {
var workingIndex = (sqLength - 1) - (nextLength - i);
var nextQ = nextQuestions;
$('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow');
}
// Some styling...
$('input[type="text"]', thisQuestion).css({
'width': '50%'
});
// Handle the "Other" radios
$('input[type="text"]', thisQuestion).on('keyup change',function(event){
event.stopPropagation();
var thisRow = $(this).closest('tr.answers-list');
if($.trim($(this).val()) == '') {
$('input:radio[value!=""]', thisRow).prop('checked',false);
$('input:radio[value=""]', thisRow).click();
}
else {
$('input:radio[value=""]', thisRow).prop('checked',false);
}
});
// Handle the "Other" text input
$('.otherRow input.radio', thisQuestion).on('click',function(event){
var thisRow = $(this).closest('tr.answers-list');
if($(this).attr('value') == '') {
$('input[type="text"]', thisRow).val('');
}
});
// Validate the "Other" text input(s) on submit
if($('#movenextbtn, #movesubmitbtn').attr('data-inserted-other') != 'true') { // We're only doing this once on this page
$('#movenextbtn, #movesubmitbtn').attr('data-inserted-other', 'true').on('click.insertedOther', function (event) {
var otherError = 0;
$('.array-flexible-row .otherRow').each(function(i) {
if(($('input:radio[value!=""]:checked', this).length > 0 && $('input[type="text"]', this).val() == '') || ($('input:radio[value!=""]:checked', this).length == 0 && $('input[type="text"]', this).val() != '')) {
otherError = 1;
}
});
if(otherError == 1) {
alert('Please review your answer in the "Other" row(s).');
return false;
}
});
}
});
</script>
this is the script
thanks
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var thisQuestion = $('#question'+{QID}+'');
var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)');
var nextQuestion2 = $(thisQuestion).nextAll('.text-short:eq(1)');
var nextQuestion3 = $(thisQuestion).nextAll('.text-short:eq(2)');
var nextQuestions = $(nextQuestion1).add(nextQuestion2).add(nextQuestion3);
var nextLength = nextQuestions.length;
var sqLength = ('tr.answers-list', thisQuestion).length;
// Hide the short-text question
$(nextQuestions).hide();
// Move the hidden text inputs into the array
for (i = 0; i < nextLength; i++) {
var workingIndex = (sqLength - 1) - (nextLength - i);
var nextQ = nextQuestions;
$('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow');
}
// Some styling...
$('input[type="text"]', thisQuestion).css({
'width': '50%'
});
// Handle the "Other" radios
$('input[type="text"]', thisQuestion).on('keyup change',function(event){
event.stopPropagation();
var thisRow = $(this).closest('tr.answers-list');
if($.trim($(this).val()) == '') {
$('input:radio[value!=""]', thisRow).prop('checked',false);
$('input:radio[value=""]', thisRow).click();
}
else {
$('input:radio[value=""]', thisRow).prop('checked',false);
}
});
// Handle the "Other" text input
$('.otherRow input.radio', thisQuestion).on('click',function(event){
var thisRow = $(this).closest('tr.answers-list');
if($(this).attr('value') == '') {
$('input[type="text"]', thisRow).val('');
}
});
// Validate the "Other" text input(s) on submit
if($('#movenextbtn, #movesubmitbtn').attr('data-inserted-other') != 'true') { // We're only doing this once on this page
$('#movenextbtn, #movesubmitbtn').attr('data-inserted-other', 'true').on('click.insertedOther', function (event) {
var otherError = 0;
$('.array-flexible-row .otherRow').each(function(i) {
if(($('input:radio[value!=""]:checked', this).length > 0 && $('input[type="text"]', this).val() == '') || ($('input:radio[value!=""]:checked', this).length == 0 && $('input[type="text"]', this).val() != '')) {
otherError = 1;
}
});
if(otherError == 1) {
alert('Please review your answer in the "Other" row(s).');
return false;
}
});
}
});
</script>
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12713
- Thank you received: 3924
6 years 4 months ago - 6 years 4 months ago #159951
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic put the other´s textbox in a X Axis
Hello, Miguel,
you asked this already three days ago here:
www.limesurvey.org/forum/can-i-do-this-w...swer?start=30#159901
So, please mention in one of the two threads that you did this.
Otherwise you may get answers in both by different people, who don't know about the other question, and may waste their time answering again to an already answered question.
Regards
Joffm
you asked this already three days ago here:
www.limesurvey.org/forum/can-i-do-this-w...swer?start=30#159901
So, please mention in one of the two threads that you did this.
Otherwise you may get answers in both by different people, who don't know about the other question, and may waste their time answering again to an already answered question.
Regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 4 months ago by Joffm.
The following user(s) said Thank You: DenisChenu
The topic has been locked.