I would like to get the question Id using javascript and concatenation.
Let’s suppose I have a question that has a code: Ph1.
The expression written by hand {Ph1.qid} works very well.
But I need to iterate through a certain number of questions that have names:
Ph1,Ph2,Ph3 respectively.
So in js I try:
var number = 1;
var baseCode = 'Ph';
var qid = '\{' + baseCode + number.toString() + '.qid\}';
console.log(qid);
This returns the literal string ‘{Ph1.qid}’ instead of an actual qid code.
How can I do this?
You cannot use JavaScript to define Expression Manager variable names. EM is rendered at the server level but JavaScript is not rendered until after the page is loaded so it cannot modify the EM variable name.
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Thanks tpartner. I was trying to give the possibility to show only questions the user chooses to answer.
Could you advice me some workaround for this problem?
The situation:
Choose a question:
a - Ph
b - In
c - Ac
if answer == Ph :
(#question{Ph1.qid}.show #question{Ph2.qid}.show #question{Ph3.qid}.show)
These 3 questions are: Array and two huge free text.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.