Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: custom functions

Re:custom functions 4 years 3 months ago #44191

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
Also take a look at further JS examples at docs.limesurvey.org/tiki-index.php?page=...tions+for+LimeSurvey

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re:custom functions 4 years 1 week ago #48201

  • sociolog
  • sociolog's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 10
  • Karma: 0
Hi,
I still don't understand how to activate these functions. I understand that first I should modify endpage.pstpl in Template Editor so it looks exactly like this:

</td>
</tr>
</table>
<script>
// only call if it's defined
if(typeof Custom_On_Load == 'function'){
Custom_On_Load();
}
</script>
</body>

After that, it says I should test it by using this script in the question definitions:

<script>
function Custom_On_Load(){
alert('onload alert!');
}
</script>

Now, I don't understand where exactly I should add this test code. What are the "question definitions" and where can I find them in order to modify them? Does this refer to the question title that can be modified via the GUI (under "Edit current question")? Or is it somewhere else?
The administrator has disabled public write access.

Re:custom functions 4 years 1 week ago #48204

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2675
  • Thank you received: 323
  • Karma: 121
As far as I know you need to include the Javascript code in the text box for the question text. But don't forget to switch off the editor, otherwise it will probably be corrupted.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re:custom functions 4 years 1 week ago #48207

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Like holch say, you can put javascript in the question box, you can put too in the help box.

Deactivate the html editor , and put this in help box.
<script>
jQuery(document).ready(
function(){
alert('onload alert!');
}
);
</script>
The administrator has disabled public write access.

Re:custom functions 4 years 1 week ago #48209

  • sociolog
  • sociolog's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 10
  • Karma: 0
I deactivated the HTML editor by clicking on my username (admin) and put the script in the Help box and it works.
Thank you for the help!
The administrator has disabled public write access.

Re:custom functions 4 years 1 week ago #48239

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
Javascruipt always has to be added in source code mode: docs.limesurvey.org/tiki-index.php?page=...#X._Source_code_mode:

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re:custom functions 3 years 11 months ago #49898

  • sociolog
  • sociolog's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 10
  • Karma: 0
OK. Say I have a question called "What is your age", with the code a1 and the ID 11700, using the default template. And I want to hide the whole row with the question name, so that only the answer is shown, but only for question a1. I activated javascript. What should I put in the source code of the question? I tried this code, but it didn't work.

<script>
jQuery(document).ready(
function(){
document.getElementById("questiontext11700").style.display='none';
}
);
</script>

I probably don't know how to call the question by id. Can you help me, please?

EDIT: I got it to work! I just used this script, putting the question ID (11700 after div#question) and it seems to work fine (hope it works in Internet Explorer too).

<script>
jQuery(document).ready(
function(){
$('div#question11700 td.questiontext').parent().hide();
}
);
</script>
Last Edit: 3 years 11 months ago by sociolog. Reason: found out
The administrator has disabled public write access.

Re:custom functions 3 years 11 months ago #50123

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re:custom functions 3 years 11 months ago #50151

  • sociolog
  • sociolog's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 10
  • Karma: 0
Thank you. I have already made a donation, and if I can persuade my current team leader, I will make another one next month.
Regards,
Vlad
The administrator has disabled public write access.

Re:custom functions 3 years 11 months ago #50193

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.182 seconds
Donation Image