Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: insertans in template.js

insertans in template.js 2 Jahre 4 Monate her #71077

  • ResearchOnBlogs
  • ResearchOnBlogss Avatar
  • OFFLINE
  • Gold Lime
  • Beiträge: 184
  • Dank erhalten: 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
Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Aw: insertans in template.js 2 Jahre 4 Monate her #71121

  • Steve
  • Steves Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 494
  • Dank erhalten: 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: insertans in template.js 2 Jahre 4 Monate her #71123

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 81
  • 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: insertans in template.js 2 Jahre 4 Monate her #71128

  • ResearchOnBlogs
  • ResearchOnBlogss Avatar
  • OFFLINE
  • Gold Lime
  • Beiträge: 184
  • Dank erhalten: 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
Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Aw: Re: Aw: insertans in template.js 1 Jahr 7 Monate her #85297

  • ResearchOnBlogs
  • ResearchOnBlogss Avatar
  • OFFLINE
  • Gold Lime
  • Beiträge: 184
  • Dank erhalten: 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
Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: Re: Aw: insertans in template.js 1 Jahr 6 Monate her #86295

  • TAdams
  • TAdamss Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Dank erhalten: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: Re: Aw: insertans in template.js 1 Jahr 6 Monate her #86297

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 81
  • 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: insertans in template.js 10 Monate 2 Tage her #97295

  • laxwcrb73c
  • laxwcrb73cs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: insertans in template.js 10 Monate 1 Tag her #97311

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 5875
  • Dank erhalten: 722
  • Karma: 223
axelhuizinga schrieb:
Where should I report this?
www.limesurvey.org/en/community-services/bug-tracker
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.439 Sekunden
Donation Image