Welcome to the LimeSurvey Community Forum

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

Multiple Short Text values as inputs to follow up questions

  • bentoner
  • bentoner's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #199016 by bentoner
I would like my survey to allow the user to enter a list of free text which become inputs into following questions.

It looks like it should be possible using the multiple short text (Type:Q) question. I saw it on other forum questions. But it is not working - I cannot get that question type to create new inputs as the user needs them. In fact it is totally blank - no input boxes at all.

I've actually selected the input on demand question and can see the "Auto-add new line" setting. But no matter what I do, no input text box shows up. If I have Auto-add new line set to 'no', there is a nice button called "+ Add Line" but when pressed it just disappears.

Am I missing something.


I have tried to debug this a bit and can see that in the HTML a "selector--inputondemand-list" is being created but there is nothing more inside that div.

In the javascript (inputondemand.js) I see that it tries to traverse the inputondemand-list looking for a inputondemand-list-item and because that element is not existing on the page, it fails and hides the button.

It feels like I'm missing something but everything I try is failing.

I'm using a self installed version 4.2.1

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199045 by tpartner
This question theme is broken in 4.x. Bug reported - bugs.limesurvey.org/view.php?id=16260

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: DenisChenu, bentoner
The topic has been locked.
  • bentoner
  • bentoner's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #199165 by bentoner
Thanks.
I am using the workaround for now: manual.limesurvey.org/Workarounds:_Manip...ble_Text.29_question

It's all fine but I modified it to make it a bit better when removing rows so that subsequent questions which use the row content instantly update (remove reference to content) as soon as the row is removed. It works because I filter the subquestions of subsequent questions like this:
!is_empty(G14Q00002_AO00_SQ01) (enumerated per row)

Posting mod here in case someone finds it useful.
Update the removeRow function by adding in the line

$( arrayRow + '[name="visible"]:last input[type="text"]' ).trigger("change")

Full function below.

// Function to remove a row, also clears the contents of the removed row,
// shows the Add element if the last row is hidden and hides the Remove
// element if only the first row is shown
function removeRow(qID) {
var arrayRow = '#question' + qID + ' table.ls-answers tr.subquestion-list';
var rowCount = $( arrayRow ).size() - 1;
$( arrayRow + '[name="visible"]:last input[type="text"]' ).val('');
$( arrayRow + '[name="visible"]:last input[type="text"]' ).trigger("change")
$( arrayRow + '[name="visible"]:last' ).attr('name', 'hidden').hide();
$( 'div#addButton'+qID ).show();
if ( $( arrayRow + ':eq(1)' ).attr('name') == 'hidden' ) {
$( 'div#removeButton'+qID ).hide();
}
}

Ben
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose