Welcome, Guest
Username: Password: Remember me

TOPIC: insertans in template.js

insertans in template.js 2 years 10 months ago #71077

  • ResearchOnBlogs
  • ResearchOnBlogs's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 184
  • Thank you received: 16
  • Karma: 8
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.
The administrator has disabled public write access.

Aw: insertans in template.js 2 years 10 months ago #71121

  • Steve
  • Steve's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 494
  • Thank you received: 46
  • Karma: 17
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
The administrator has disabled public write access.

Re: Aw: insertans in template.js 2 years 10 months ago #71123

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
roB2009-

In LimeSurvey 1.92 (which should be available as a release candidate this week), you can use the new Expression ManagerJavaScript 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
The administrator has disabled public write access.

Re: Aw: insertans in template.js 2 years 10 months ago #71128

  • ResearchOnBlogs
  • ResearchOnBlogs's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 184
  • Thank you received: 16
  • Karma: 8
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.
The administrator has disabled public write access.

Aw: Re: Aw: insertans in template.js 2 years 1 month ago #85297

  • ResearchOnBlogs
  • ResearchOnBlogs's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 184
  • Thank you received: 16
  • Karma: 8
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.
The administrator has disabled public write access.

Re: Aw: Re: Aw: insertans in template.js 2 years 2 weeks ago #86295

  • TAdams
  • TAdams's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Thank you received: 1
  • Karma: 0
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.
The administrator has disabled public write access.

Re: Aw: Re: Aw: insertans in template.js 2 years 2 weeks ago #86297

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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.
The administrator has disabled public write access.

Re: Aw: insertans in template.js 1 year 3 months ago #97295

  • laxwcrb73c
  • laxwcrb73c's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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
The administrator has disabled public write access.

Re: Aw: insertans in template.js 1 year 3 months ago #97311

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6435
  • Thank you received: 840
  • Karma: 249
axelhuizinga wrote:
Where should I report this?
www.limesurvey.org/en/community-services/bug-tracker
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.396 seconds
Donation Image