Check out the LimeSurvey source code on GitHub!

custom functions

More
6 years 8 months ago #44191 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 5 months ago #48201 by sociolog
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?

Please Log in to join the conversation.

More
6 years 5 months ago #48204 by holch
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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
6 years 5 months ago #48207 by DenisChenu
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>

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.

More
6 years 5 months ago #48209 by sociolog
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!

Please Log in to join the conversation.

More
6 years 5 months ago #48239 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 4 months ago - 6 years 4 months ago #49898 by sociolog
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: 6 years 4 months ago by sociolog. Reason: found out

Please Log in to join the conversation.

More
6 years 4 months ago #50123 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 4 months ago #50151 by sociolog
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

Please Log in to join the conversation.

More
6 years 4 months ago #50193 by Mazi
Thanks!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form