Welcome to the LimeSurvey Community Forum

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

Executing hidden question

More
10 years 11 months ago #94533 by kubaj
Executing hidden question was created 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)?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago #94566 by tpartner
Replied by tpartner on topic Executing hidden question
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:
Code:
$('#questionQQ').hide();

Or with CSS:
Code:
#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.
The topic has been locked.
More
10 years 11 months ago - 10 years 11 months ago #94587 by kubaj
Replied by kubaj on topic Executing hidden question
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: 10 years 11 months ago by kubaj.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago - 10 years 11 months ago #94596 by tpartner
Replied by tpartner on topic Executing hidden question

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: 10 years 11 months ago by tpartner.
The topic has been locked.
More
10 years 11 months ago #94651 by kubaj
Replied by kubaj on topic Executing hidden question
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';}
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago - 10 years 11 months ago #94657 by DenisChenu
Replied by DenisChenu on topic Executing hidden question
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 , plugin development .
I don't answer to private message.
Last edit: 10 years 11 months ago by DenisChenu.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose