Java without deactivating XSS Filter?

More
4 months 1 day ago #167478 by Inpanic26
Inpanic26 created the topic: Java without deactivating XSS Filter?
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!

Please Log in or Create an account to join the conversation.

More
4 months 1 day ago #167491 by tpartner
tpartner replied the 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}.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
4 months 1 day ago #167500 by Inpanic26
Inpanic26 replied the 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
<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>
 
 

Please Log in or Create an account to join the conversation.

More
4 months 1 day ago #167504 by tpartner
tpartner replied the topic: Java without deactivating XSS Filter?
You can hard-code the question ID. Something like this, where "9825" is your question ID:

$(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

Please Log in or Create an account to join the conversation.

More
4 months 1 day ago #167510 by Inpanic26
Inpanic26 replied the topic: Java without deactivating XSS Filter?
Worked out great. Thank you so much!

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!