Modify array question type?

More
5 years 6 months ago #81023 by piquadrat
piquadrat created the topic: Modify array question type?
Hello Limesurvey community,

is there any chance to add text in the upper left cell in an array question type (see red marked cell in attached picture)?

Thanks
Phil

Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #81038 by tpartner
tpartner replied the topic: Modify array question type?
Not out-of-the-box, but you can insert the text with JavaScript.

1) Set up your survey to use JavaScript .

2)Add the following script to the source of the array. Replace "QQ" with the array question ID .

The script adds a class to the cell for styling and inserts the text defined by newText.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		var qID = QQ;
		var newtext = 'Some inserted text...';
 
		$('#question'+qID+' table.question thead td').text(newtext).addClass('insertedText');
	});
 
</script>

3) Add something like the following to the end of template.css to style the inserted text.
td.insertedText {
	text-align: right;
	vertical-align: bottom;
	color: red;
}


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: piquadrat

Please Log in to join the conversation.

More
5 years 6 months ago #81042 by piquadrat
piquadrat replied the topic: Aw: Modify array question type?
Thank you Tony!

Unfortunately your solution seem to exaggerate the job ;)

The script replaces all cells with the same text (see picture below). Any idea how to avoid this?

And do you think it's possible to add html code in the "Some inserted text..." field as well?

Thanks again for your help! Much appreciated!

Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #81044 by tpartner
tpartner replied the topic: Aw: Modify array question type?
I tested with the default template. What template are you using and what question type?

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

Please Log in to join the conversation.

More
5 years 6 months ago #81051 by piquadrat
piquadrat replied the topic: Aw: Modify array question type?
I use a slighty different template, however, I just doublechecked with the default template, which ends up with the same "error".

I'm using the array question type (translated as "Matrix" in German). However, I use custom answers. These are tables implemented by html code (see picture below).




I assume that there is a crossover conflict.
Attachments:

Please Log in to join the conversation.

More
5 years 6 months ago #81054 by tpartner
tpartner replied the topic: Modify array question type?
Yes, that will cause a problem.

Try this:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		var qID = QQ;
		var newtext = 'Some inserted text...';
 
		$('#question'+qID+' table.question thead > tr > td').text(newtext).addClass('insertedText');
	});
 
</script>

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: piquadrat

Please Log in to join the conversation.

More
5 years 6 months ago #81055 by tpartner
tpartner replied the topic: Aw: Modify array question type?
Oh, yeah, and for inserting HTML:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		var qID = QQ;
		var newhtml = '<table><tr><td>Some inserted HTML...</td></tr></table>';
 
		$('#question'+qID+' table.question thead > tr > td').html(newhtml).addClass('insertedText');
	});
 
</script>

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: piquadrat

Please Log in to join the conversation.

More
5 years 6 months ago #81078 by piquadrat
piquadrat replied the topic: Aw: Re: Aw: Modify array question type?
Tony! Thank you so much!

Your solution just works wonderful now!

Your help is much appreciated! :)

Please Log in to join the conversation.

More
1 month 4 weeks ago #159705 by tpartner
tpartner replied the topic: Aw: Re: Aw: Modify array question type?
This is a 5-year-old thread and you haven't explained what the problem is. Please be more specific or open a new topic.

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

Please Log in to join the conversation.

More
1 month 4 weeks ago #159706 by Joffm
Joffm replied the topic: Aw: Re: Aw: Modify array question type?
Tony, do not answer him/her.

emilyjohn always writes something into old old threads.
Mostly just copies some text from former posts.

Same here. The text is from a former piquadrat post.

Sometimes I think it is alcohol or other drugs influenced. (sorry)

Joffm
The following user(s) said Thank You: tpartner, LouisGac

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #159870 by c_schmitz
c_schmitz replied the topic: Aw: Re: Aw: Modify array question type?
The person is banned now and all her messages are removed - all of them were generic.
I'd guess it is a spam bot gone wrong.

Best regards

Carsten Schmitz
LimeSurvey project leader
Last Edit: 1 month 3 weeks ago by c_schmitz.
The following user(s) said Thank You: LouisGac

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!