Welcome to the LimeSurvey Community Forum

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

Adding textbox in basic array

More
5 years 4 months ago #197697 by Chrisou
This is probably a very basic question, but how do I import or open this in LS?

Thanks for the tip, I have version 3.22.12.
The topic has been locked.
More
5 years 4 months ago #197699 by holch
Replied by holch on topic Adding textbox in basic array
yes, this is very, very, very, very basic.


Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: Chrisou
The topic has been locked.
More
5 years 4 months ago #197703 by Chrisou
Thank you both very much, I should be able to figure this out now (hopefully) :)
The topic has been locked.
More
5 years 4 months ago #197755 by Chrisou
I'm happy to report that I have successfully added the script to all my questions and the text box is showing as it should - again, thank you so much!

However, I forgot an important detail: I'd like to randomise my questions, while showing them all on the same page.
Therefore, I put everything in the same question group, but now I'm wondering if the comment boxes will appear with the right questions?
The topic has been locked.
More
5 years 4 months ago #197756 by Joffm
Replied by Joffm on topic Adding textbox in basic array

but now I'm wondering if the comment boxes will appear with the right questions?

Do they? Or not?
Try. Activate the survey, enter some well defined data, and then check the answer table.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
5 years 4 months ago #197764 by Chrisou
It's all a big mess.

If I put everything in the same randomisation group, LS will sometimes put two "comment boxes" together to create something like you see attached. If I only randomise the actual questions, they will randomise, but the comments stay in the order I put them in originally
The topic has been locked.
More
5 years 4 months ago #197785 by DenisChenu
This topic is to big to be readed … and title seems not related to randomization

Maybe time to create own topic ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
5 years 2 months ago #202525 by kratugoel
Hi

I was wondering if we could add one large comment box for the entire question as opposed to each row. I see most responses for adding a comment box to each row but couldn't find one for just one box for the question. Could I get some assistance on this?

I am using Version 3.22.24+200630.

Thank you
The topic has been locked.
More
5 years 2 months ago #202528 by Joffm
Replied by Joffm on topic Adding textbox in basic array
Something like this?

Use two questions and adapt the css.

In this example I used the skelvanilla theme.

Here the necessary classes are built in.

And here fruity

with these settings.
I gave the array question a css class "myarray" and the text question a css class "mytext"
Code:
<style type="text/css">.mytext .question-title-container, .mytext .question-valid-container {
  display:none;}
.myarray .question-container {
    margin-bottom: 0em;
}
</style>

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
5 years 2 months ago #202534 by kratugoel
Thank you for the quick response. Was hoping to actually have a comment box template like the one shared here which leads to a pop-up text box. Is that possible? This would work well otherwise. Thank you
The topic has been locked.
More
5 years 2 months ago - 5 years 2 months ago #202535 by DenisChenu

Joffm wrote: In this example I used the skelvanilla theme.

I muts create more saple with SkelVanilla,

In fact it's included in Css class

1st question must have `skel-start-group-question` class
Next questions can have (must ?) skel-wrap-none
Last question must have ``skel-end-group`

This can make something like this easily


extensions.sondages.pro/themes-and-templ...b-group-inside-group

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
Last edit: 5 years 2 months ago by DenisChenu. Reason: img didn't work
The topic has been locked.
More
5 years 2 months ago #202551 by Joffm
Replied by Joffm on topic Adding textbox in basic array
If you want something like a popup, please say it.
There is, as far as I remember, a solution with a button - you need something to trigger it.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
5 years 2 months ago #202555 by kratugoel
I am not sure how do I trigger it? Would you have any suggestions or links to the solution for that? Apologies if my initial message wasn't clear. I would like to present the pop-up to my team as an added bonus.

Thank you for your help
The topic has been locked.
More
5 years 2 months ago - 5 years 2 months ago #202567 by Joffm
Replied by Joffm on topic Adding textbox in basic array
Hi,you already found this solution, didn't you?
forums.limesurvey.org/forum/can-i-do-thi...ment-fields?start=15

I adapted the script by removing everything related to the array rows, put the button into the question text and got:




First the button (a simple bootstrap button):
Code:
<button class="btn btn-default btn-xs" data-backdrop="static" data-keyboard="false" data-target="#comments-{QID}-1" data-toggle="modal" type="button">Click to add a comment</button>

and the script:
Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify the questions
    var qArrayID = {QID};
    var qArray = $('#question'+qArrayID);
    var arrayLength = $('tr.answers-list', qArray).length;
    var qComments = qArray.nextAll('.text-long:lt('+arrayLength+')');
 
 
    // Add some classes
    qArray.addClass('array-with-comments-question');
    $(qComments).each(function(i) {
      $(this).addClass('comments-question index-'+i).css({
        'position': 'absolute',
        'left': '-9999em'
      });
    });
 
    // Handle comments
    $(qComments).each(function(i) {
      // Create modals
      $('body').append('<div class="modal comments-modal" id="comments-'+qArrayID+'-'+(i+1)+'" tabindex="-1" role="dialog">\
                <div class="modal-dialog" role="document">\
                  <div class="modal-content">\
                    <div class="modal-header">\
                      <h5 class="modal-title">'+$('.ls-label-question', this).html()+'</h5>\
                    </div>\
                    <div class="modal-body">\
                    </div>\
                    <div class="modal-footer">\
                      <button type="button" class="btn btn-primary" data-bs-dismiss="modal">Okay</button>\
                      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Clear</button>\
                    </div>\
                  </div>\
                </div>\
              </div>');
 
      // Move textareas into modals
      $('#comments-'+qArrayID+'-'+(i+1)+' .modal-body').append($('textarea', this));
 
      // Modal button events
      $('#comments-'+qArrayID+'-'+(i+1)+' .modal-footer .btn-secondary').on('click', function(e) {
        $('#comments-'+qArrayID+'-'+(i+1)+' textarea').val('');
      });
 
    });
 
    // Interrupt the Next/Submit function (to put comments back in the form)
    $('#limesurvey').submit(function(e) {
      $('.comments-modal[id^="comments-'+qArrayID+'-"]').each(function(i) {
        var qID = $('textarea:eq(0)', this).attr('id').split('X')[2];
        $('#question'+qID+' .answer-item:eq(0)').append($('textarea:eq(0)', this));
      });
    });  
  });
</script>

File Attachment:

File Name: limesurvey...5391.lss
File Size:22.45 KB


Joffm

The script can be simplified more ( there is only one comment); so no need to use the each-function.
But I am not familiar at all with javascript. It's only Amateurishness.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 5 years 2 months ago by Joffm.
The following user(s) said Thank You: kratugoel
The topic has been locked.
More
5 years 1 month ago #203208 by kratugoel
Hi

I am trying to implement this solution but I am not able to. Would you happen to have a sample survey depicting this solution? Thank you for the assistance.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose