Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Broken javascript upgrading from 2.00 to 2.06

  • emmacallegari
  • emmacallegari's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 8 months ago #122694 by emmacallegari
Broken javascript upgrading from 2.00 to 2.06 was created by emmacallegari
Upgraded LimeSurvey from 2.00 to 2.06 and having issues with array(numbers) question types that have multiple dropdown columns (see lsq file attached). The dropdowns are now appearing as the value number not as the text (see screenshot attached)

The code used it:
<p>
</p>
<p>
<span style="font-size:14px;"><span style="font-family: arial,helvetica,sans-serif;">Please indicate if and when you have had any of the following medical conditions, operations, illnesses or accidents?</span></span><br />
<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

var thisQuestion = $('#question{QID}');

$(thisQuestion + '.answer_cell_00SQ001 option[value=1]').text('Yes');
$(thisQuestion + '.answer_cell_00SQ001 option[value=2]').text('No');
$(thisQuestion + '.answer_cell_00SQ001 option[value=3]').text('Don’t know');
$(thisQuestion + '.answer_cell_00SQ001 option[value=4]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=5]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=6]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=7]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=8]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=9]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=10]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=11]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=12]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=13]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=14]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=15]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=16]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=17]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=18]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=19]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=20]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=21]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=22]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=23]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=24]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=25]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=26]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=27]').text('').hide();
$(thisQuestion + '.answer_cell_00SQ001 option[value=28]').text('').hide();

$(thisQuestion + '.answer_cell_00SQ002 option[value=1]').text('Not applicable');
$(thisQuestion + '.answer_cell_00SQ002 option[value=2]').text('Can’t remember');
$(thisQuestion + '.answer_cell_00SQ002 option[value=3]').text('0');
$(thisQuestion + '.answer_cell_00SQ002 option[value=4]').text('1');
$(thisQuestion + '.answer_cell_00SQ002 option[value=5]').text('2');
$(thisQuestion + '.answer_cell_00SQ002 option[value=6]').text('3');
$(thisQuestion + '.answer_cell_00SQ002 option[value=7]').text('4');
$(thisQuestion + '.answer_cell_00SQ002 option[value=8]').text('5');
$(thisQuestion + '.answer_cell_00SQ002 option[value=9]').text('6');
$(thisQuestion + '.answer_cell_00SQ002 option[value=10]').text('7');
$(thisQuestion + '.answer_cell_00SQ002 option[value=11]').text('8');
$(thisQuestion + '.answer_cell_00SQ002 option[value=12]').text('9');
$(thisQuestion + '.answer_cell_00SQ002 option[value=13]').text('10');
$(thisQuestion + '.answer_cell_00SQ002 option[value=14]').text('11');
$(thisQuestion + '.answer_cell_00SQ002 option[value=15]').text('12');
$(thisQuestion + '.answer_cell_00SQ002 option[value=16]').text('13');
$(thisQuestion + '.answer_cell_00SQ002 option[value=17]').text('14');
$(thisQuestion + '.answer_cell_00SQ002 option[value=18]').text('15');
$(thisQuestion + '.answer_cell_00SQ002 option[value=19]').text('16');
$(thisQuestion + '.answer_cell_00SQ002 option[value=20]').text('17');
$(thisQuestion + '.answer_cell_00SQ002 option[value=21]').text('18');
$(thisQuestion + '.answer_cell_00SQ002 option[value=22]').text('19');
$(thisQuestion + '.answer_cell_00SQ002 option[value=23]').text('20');
$(thisQuestion + '.answer_cell_00SQ002 option[value=24]').text('21');
$(thisQuestion + '.answer_cell_00SQ002 option[value=25]').text('22');
$(thisQuestion + '.answer_cell_00SQ002 option[value=26]').text('23');
$(thisQuestion + '.answer_cell_00SQ002 option[value=27]').text('24');
$(thisQuestion + '.answer_cell_00SQ002 option[value=28]').text('25');


});

</script></p>


Here is some debugging info from the JavaScript console
Uncaught Error: Syntax error, unrecognized expression: [object Object].answer_cell_00SQ001 option[value=1]

Any ideas why this has happened or how to fix it?

Cheers,
Emma
The topic has been locked.
More
8 years 8 months ago #122695 by AdrianB
Replied by AdrianB on topic Broken javascript upgrading from 2.00 to 2.06
I ran into this problem too and have not been able to find a solution yet. Any help would be greatly appreciated!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 8 months ago #122710 by DenisChenu
Replied by DenisChenu on topic Broken javascript upgrading from 2.00 to 2.06
Hi,

js seems strange here, and with:
Code:
$(thisQuestion).find('.answer_cell_00SQ002 option[value=28]').text('25');

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
8 years 8 months ago #122722 by AdrianB
Replied by AdrianB on topic Broken javascript upgrading from 2.00 to 2.06
Hi Denis,

Many thanks, using your example appears to have fixed the problem.

I'm a little curious about why Emma's code worked with v2.00 and not 2.06, but that's something to figure out in spare time.

Thanks again,
A.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 8 months ago #122723 by DenisChenu
Replied by DenisChenu on topic Broken javascript upgrading from 2.00 to 2.06
Hi don't understand how emma script can work with jquery.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
8 years 8 months ago #122724 by AdrianB
Replied by AdrianB on topic Broken javascript upgrading from 2.00 to 2.06
The code that Emma and me have been using comes from tpartner's responses in this thread: www.limesurvey.org/en/forum/can-i-do-thi...rs-in-dropdown-boxes

Specifically post 58244 . Later in post 109834 the user reports that code was working, but becomes broken, and on page 3 of the thread tpartner mentions a jquery version update might be the cause.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 8 months ago - 8 years 8 months ago #122725 by DenisChenu
Replied by DenisChenu on topic Broken javascript upgrading from 2.00 to 2.06
Tony code,
Not use {QID}
Code:
$('#question298 .answer_cell_00SQ001 option[value=1]').text('No recurro');
Then using QID:
Code:
$('#question{QID} .answer_cell_00SQ001 option[value=1]').text('No recurro');

Emma code:
Code:
var thisQuestion = $('#question{QID}');
$(thisQuestion + '.answer_cell_00SQ001 option[value=1]').text('Yes');

Not the same ....
thisQuestion = $('#question{QID}'); make a jquery object, no a string.
To do it with a string var:
Code:
var thisStringQuestion = '#question{QID}';
$(thisStringQuestion + ' .answer_cell_00SQ001 option[value=1]').text('Yes');
(adding a space between id and class)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 8 years 8 months ago by DenisChenu.
The topic has been locked.
More
8 years 8 months ago #122726 by AdrianB
Replied by AdrianB on topic Broken javascript upgrading from 2.00 to 2.06
Ah, that makes sense! Thank you for your clear explanation. :)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose