Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Modify array question type?

  • piquadrat
  • piquadrat's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 9 months ago #81023 by piquadrat
Modify array question type? was created by piquadrat
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:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 9 months ago #81038 by tpartner
Replied by tpartner on 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.
Code:
<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.
Code:
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.
The following user(s) said Thank You: piquadrat
The topic has been locked.
  • piquadrat
  • piquadrat's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 9 months ago #81042 by piquadrat
Replied by piquadrat on 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:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 9 months ago #81044 by tpartner
Replied by tpartner on 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.
The topic has been locked.
  • piquadrat
  • piquadrat's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 9 months ago #81051 by piquadrat
Replied by piquadrat on 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:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 9 months ago #81054 by tpartner
Replied by tpartner on topic Modify array question type?
Yes, that will cause a problem.

Try this:
Code:
<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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 9 months ago #81055 by tpartner
Replied by tpartner on topic Aw: Modify array question type?
Oh, yeah, and for inserting HTML:
Code:
<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
The topic has been locked.
  • piquadrat
  • piquadrat's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 9 months ago #81078 by piquadrat
Replied by piquadrat on topic Aw: Re: Aw: Modify array question type?
Tony! Thank you so much!

Your solution just works wonderful now!

Your help is much appreciated! :)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 5 months ago #159705 by tpartner
Replied by tpartner on 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.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 5 months ago #159706 by Joffm
Replied by Joffm on 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

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tpartner
The topic has been locked.
  • c_schmitz
  • c_schmitz's Avatar
  • Away
  • LimeSurvey GmbH Employee
  • LimeSurvey GmbH Employee
More
6 years 4 months ago - 6 years 4 months ago #159870 by c_schmitz
Replied by c_schmitz on 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: 6 years 4 months ago by c_schmitz.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose