insertans in template.js

More
5 years 3 months ago #71077 by KRav
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 3 months ago #71121 by Steve01
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 3 months ago #71123 by TMSWhite
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 3 months ago #71128 by KRav
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 6 months ago #85297 by KRav
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 5 months ago #86295 by TAdams
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 5 months ago #86297 by TMSWhite
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
3 years 9 months ago #97295 by laxwcrb73c
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
3 years 9 months ago #97311 by DenisChenu

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).

Please Log in to join the conversation.