insertans in template.js

More
5 years 7 months ago #71077 by KRav
KRav created the topic: insertans in template.js
Hi there,
is it possible to get a INSERTANS in template.js

Tried this with no success..


$(document).ready(function(){

var value = {INSERTANS:81754X121X2121};

....

is this not possible? How to get an answer in template.js


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
5 years 7 months ago #71121 by Steve01
Steve01 replied the topic: Aw: insertans in template.js
Hello,

I'm not sure but I think you can't use INSERTANS in Javascript. If you want to get an answer in your Javascript method you could perhaps do it by getting the answer from the element itself/its value. You can get an element by using "$('SELEKTOR')" provided by JQuery. For example, if you want to get the answer from 81754X121X2121 you can try something like
var value = $('#answer81754X121X2121').val();
But I think it will depend on what question you are using or what element you try to get/access.

Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team

Please Log in to join the conversation.

More
5 years 7 months ago #71123 by TMSWhite
TMSWhite replied the topic: Aw: insertans in template.js
roB2009-

In LimeSurvey 1.92 (which should be available as a release candidate this week), you can use the new Expression Manager JavaScript functions to access the values.

Say your variable is called MyVar, you could either do this:
var value = LEMval('81754X121X2121');

or:
var value = LEMval('MyVar');

/Tom

Please Log in to join the conversation.

More
5 years 7 months ago #71128 by KRav
KRav replied the topic: Aw: insertans in template.js
thank you both, for your response


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
4 years 10 months ago #85297 by KRav
KRav replied the topic: Aw: Re: Aw: insertans in template.js
Hi Tom,

could you explain me the LEMval story a little bit more?

would it possible to "answer" a question from the template.js with it?

Pseudocode:

set radiobutton 1 of question xyx


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
4 years 9 months ago #86295 by TAdams
TAdams replied the topic: Aw: Re: Aw: insertans in template.js
Hello roB2009, I have also had trouble assigning variables with INSERTANS in Jquery. I have not had any luck with var value = LEMval('81754X121X2121');.
Have you found success?

Thank you for your feedback.

Please Log in to join the conversation.

More
4 years 9 months ago #86297 by TMSWhite
TMSWhite replied the topic: Aw: Re: Aw: insertans in template.js
TAdams-

You can only use code this:
var value = LEMval('INSERTANS:81754X121X2121');

If you also have something like this elsewhere on the page:
{INSERTANS:81754X121X2121}

or more easily (assuming that 81754X121X2121 is question q5):
{q5}

Expression Manager finds all variables within curly braces, and creates JavaScript arrays with metadata about them - but only for variables "declared" via those curly braces. So, if you use LEMval('q5') without putting {q5} somewhere on the page, LEMval() will return an empty string since there will be no entry for 'q5' in those JavaScript arrays.

Please Log in to join the conversation.

More
4 years 4 weeks ago #97295 by laxwcrb73c
laxwcrb73c replied the topic: Aw: insertans in template.js
Hi,
while trying to prefill a Date question which did not work with setting the default
answer to {INSERTANS:184361X4X41} which results in an empty field or INSERTANS:184361X4X41 which results in always 03.12.1999 regardless of the parameter given
my attempt to examine where the problem is with the help of js stumbled over a buggy behavior:

debug('date_of_birth:' + LEMval('184361X4X41'));
fails on line 384 in em_javascript.js because the jsName usually defined in a hidden input within answers
seems to be missing on the datepicker type.
Where should I report this?

Cordially,
Axel

Please Log in to join the conversation.

More
4 years 3 weeks ago #97311 by DenisChenu
DenisChenu replied the topic: Aw: insertans in template.js

axelhuizinga wrote: Where should I report this?

www.limesurvey.org/en/community-services/bug-tracker

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).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now