Check out the LimeSurvey source code on GitHub!

Executing hidden question

More
3 years 10 months ago #94533 by kubaj
Hi I have a "fake" array question which includes javascript code which automatically prefill the array with the answers filled in different variable length array questions before to get some structure to have ready variables for conditioning successive questions. The script works great I get the values. When I hide this question the javascript code is not executed. Do you have any idea how to execute the code for filling the answers but not to display this question (or whole one group of questions)?

Please Log in to join the conversation.

More
3 years 10 months ago #94566 by tpartner
If you want to manipulate a question with JavaScript you can't use the " Always hide this question" advanced setting.

You will need to hide it with JavaScript:
$('#questionQQ').hide();

Or with CSS:
#questionQQ {display: none}

(where "QQ" is the question ID)

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.

More
3 years 10 months ago - 3 years 10 months ago #94587 by kubaj
Hi, thanks - it didn't worked for me, because instead of QQ (just 1234 for example) I have put whole QID (1233X23X32). ;) Do you have any idea how to use with this relative naming for example {queestion_name} ?

I also need to hit "enter" buttons for new fields to get this work for conditioning array perfilled answers on the same page - any help for this?

Thank you very much.
Last Edit: 3 years 10 months ago by kubaj.

Please Log in to join the conversation.

More
3 years 10 months ago - 3 years 10 months ago #94596 by tpartner

Do you have any idea how to use with this relative naming for example {queestion_name} ?

Have a look at Expression Manager Access to Variables - docs.limesurvey.org/Expression+Manager&s...#Access_to_Variables

I also need to hit "enter" buttons for new fields to get this work for conditioning array perfilled answers on the same page - any help for this?

I think you are referring to triggering conditions when prefilling elements. You will need to add code to fire the checkconditions() function to your prefill script. (use a tool like Firebug to explore the keyup or change attributes of the elements)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 10 months ago by tpartner.

Please Log in to join the conversation.

More
3 years 10 months ago #94651 by kubaj
thank you - finally this code works for me now:

var aktual_SGQA = '{self.SGQA}';
var coolVarParts = aktual_SGQA.split('X'); //to get rid of sub-questions ids

var aktual_id = coolVarParts[0] + 'X' + coolVarParts[1] + 'X' + '{self.qid}';

and the usage is for example this:
for ( var i = 1; i <= 5; i++ ) {
document.getElementById('answer'+aktual_id+'rowidwithoutnumber'+i+'_columnid').value = '0';}

Please Log in to join the conversation.

More
3 years 10 months ago - 3 years 10 months ago #94657 by DenisChenu
Hello.

Think is very more easy to use:
{QID}
or
{self.qid}


QID ALLWAYS work.

Denis
PS: doc updated : docs.limesurvey.org/The+template+editor#Keywords
And add a link to keyword in EM

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Last Edit: 3 years 10 months ago by DenisChenu.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form