- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Dynamically create expression using javascript.
- czysty
- Topic Author
- Offline
- New Member
Less
More
4 years 1 month ago - 4 years 1 month ago #194341
by czysty
Dynamically create expression using javascript. was created by czysty
Hi,
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?
Thanks.
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?
Thanks.
Last edit: 4 years 1 month ago by czysty.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 1 month ago #194343
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Dynamically create expression using javascript.
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.
The topic has been locked.
- czysty
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
4 years 1 month ago - 4 years 1 month ago #194352
by czysty
Replied by czysty on topic Dynamically create expression using javascript.
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.
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.
Last edit: 4 years 1 month ago by czysty.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 1 month ago #194354
by DenisChenu
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.
Replied by DenisChenu on topic Dynamically create expression using javascript.
? Relevance is set for this ....
And here : condition editor work ...
And here : condition editor work ...
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.