Multiple Short Text values as inputs to follow up questions

More
2 months 3 days 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

Please Log in to join the conversation.

LimeSurvey Partners
More
2 months 2 days 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.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: DenisChenu, bentoner

Please Log in to join the conversation.

More
2 months 1 day 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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now