Welcome, Guest
Username: Password: Remember me

TOPIC: Modify array question type?

Modify array question type? 2 years 5 months ago #81023

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
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

array.jpg
The administrator has disabled public write access.

Re: Modify array question type? 2 years 5 months ago #81038

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
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;
}

Capture_2012-05-29.JPG
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: piquadrat

Aw: Modify array question type? 2 years 5 months ago #81042

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
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!

Example.JPG
The administrator has disabled public write access.

Re: Aw: Modify array question type? 2 years 5 months ago #81044

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Aw: Modify array question type? 2 years 5 months ago #81051

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
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).

Answers.JPG



I assume that there is a crossover conflict.
The administrator has disabled public write access.

Re: Modify array question type? 2 years 5 months ago #81054

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: piquadrat

Re: Aw: Modify array question type? 2 years 5 months ago #81055

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4356
  • Thank you received: 826
  • Karma: 381
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: piquadrat

Aw: Re: Aw: Modify array question type? 2 years 5 months ago #81078

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
Tony! Thank you so much!

Your solution just works wonderful now!

Your help is much appreciated! :)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.115 seconds
Donation Image