Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

using the em in external js file

  • realerror
  • realerror's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 2 days ago - 8 years 2 days ago #133530 by realerror
using the em in external js file was created by realerror
Hi,
I am very happy with limesurvey at the moment. There is just one thing that bothers me:
Within the completed.pstpl I need the values of all the preceding questions. So, a small part of my code looks like this:
Code:
<script type="text/javascript">
var myAnswers = {
      answer1: {sd1q1.code},
      answer2: {sd1q2.code},
      answer3: {sd1q2.code},
    }
<script>
If I debug myAnswers they are properly filled. But: Since every survey is different, I have to copy the template for each instance (and I'd like to have only one).

My Idea: execute the code as myjs.js file like this:
Code:
<script type="text/javascript" src="scripts/own/myjs.js"></script>

But: If I do it this way, the EM does not resolve the variables "{sd1q1.code}". Its just exactly this string that is executed.
Is there a known solution for this? Before you ask: The last page is supposed to show some diagrams that are depending on the answers and the chosen survey. If I had those answer values in my external js file, I could do everything with jquery and could use only one template.

ty!

E: btw: Is the german speaking board more active? I could post there too, but I guess thats not appreciated.
Last edit: 8 years 2 days ago by realerror. Reason: added btw
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 2 days ago #133543 by holch
Replied by holch on topic using the em in external js file
Please do NOT post also in the German forum. As far as I know, all relevant German participants also participate in the English forum and additionally you have access to the javascript wizard "tpartner".

To be honest, I don't think you will be able to use EM in external JS files because the file wouldn't know what EM is and therefore cans't sustitute the EM bits. At least this is my logic. But let's see what the experts on this say.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 day ago #133554 by tpartner
Replied by tpartner on topic using the em in external js file
You are correct Holch, Expression Manager is only processed in files that are rendered by LimeSurvey.

- .pstpl files
- text elements when editing the survey (questions, groups, welcome message ...)
- email templates

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 9 hours ago #133579 by DenisChenu
Replied by DenisChenu on topic using the em in external js file
You can add this easily with afterSurveySubmitted using Yii registerScript system.

Denis

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 9 hours ago #133581 by tpartner
Replied by tpartner on topic using the em in external js file
Maybe an example Denis? :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 5 hours ago #133596 by DenisChenu
Replied by DenisChenu on topic using the em in external js file
All my code are public :)

But don't have actually exactly same system.

Using afterSurveyComplete : git.framasoft.org/SondagePro-LimeSurvey-...Information.php#L197
Add a script : git.framasoft.org/SondagePro-LimeSurvey-...ayTextAdapt.php#L276

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.
  • realerror
  • realerror's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #133674 by realerror
Replied by realerror on topic using the em in external js file
sorry for the late answer, the holidays distracted me a little.
Thanks for your answers, I expected there wouldnt be an "onboard solution". Therefore I'll have a look at DenisChenu's solution and if I can handle it, I'm not very experienced with js.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose