- Posts: 6
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Java without deactivating XSS Filter?
- Inpanic26
- Topic Author
- Offline
- New Member
Less
More
5 years 11 months ago #167478
by Inpanic26
Java without deactivating XSS Filter? was created by Inpanic26
Hello guys,
I want to create an array question with an "Other" option at the end. I found already several ways to do that with Javascript. Unfortunately, due to safety reasons I am not allowed to deactivate the XSS Filter. Is there any other way to use Javascript (eg. in the template) and if not, is there a way to create this question without using Java?
I am using Version 2.50+ Build 160804
Thanks for yout time and help!
I want to create an array question with an "Other" option at the end. I found already several ways to do that with Javascript. Unfortunately, due to safety reasons I am not allowed to deactivate the XSS Filter. Is there any other way to use Javascript (eg. in the template) and if not, is there a way to create this question without using Java?
I am using Version 2.50+ Build 160804
Thanks for yout time and help!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10629
- Thank you received: 3696
5 years 11 months ago #167491
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Java without deactivating XSS Filter?
Place your JS in template.js or custom.js (depending on the LimeSurvey version)
Note that you will not be able to use placeholders like {QID}.
Note that you will not be able to use placeholders like {QID}.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Inpanic26
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
5 years 11 months ago #167500
by Inpanic26
Replied by Inpanic26 on topic Java without deactivating XSS Filter?
Dear tpartner,
thanks for your answer. What would I use instead {QID}? My plan was to use one of your scripts which I found in the LS forum(shown below). Would that even work or am I completly on the wrong track?
Best Regards
thanks for your answer. What would I use instead {QID}? My plan was to use one of your scripts which I found in the LS forum(shown below). Would that even work or am I completly on the wrong track?
Best Regards
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var q1 = $('#question'+{QID}+''); var q2 = $(q1).nextAll('.text-short:eq(0)'); // Hide the short-text question $(q2).hide(); // Move the hidden text input into the array $('th.answertext:last', q1).append($('input[type="text"]', q2)); // Some styling... $('input[type="text"]', q1).css({ 'width': '50%' }); }); </script>
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10629
- Thank you received: 3696
5 years 11 months ago #167504
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Java without deactivating XSS Filter?
You can hard-code the question ID. Something like this, where "9825" is your question ID:
Code:
$(document).ready(function() { if($('#question9825').length > 0) { // Identify the questions var q1 = $('#question9825'); var q2 = $(q1).nextAll('.text-short:eq(0)'); // Hide the short-text question $(q2).hide(); // Move the hidden text input into the array $('th.answertext:last', q1).append($('input[type="text"]', q2)); // Some styling... $('input[type="text"]', q1).css({ 'width': '50%' }); } });
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: Inpanic26
The topic has been locked.
- Inpanic26
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
5 years 11 months ago #167510
by Inpanic26
Replied by Inpanic26 on topic Java without deactivating XSS Filter?
Worked out great. Thank you so much!
The topic has been locked.