Welcome to the LimeSurvey Community Forum

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

Radio button and textbox combined in one question

  • fenden
  • fenden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 11 months ago #95388 by fenden
Dear LimeSurvey Team,

I'm trying to create a question (default template) in which the user can either type in text into a (free standing) text box or enable a radiobutton. The both input types shall appear one below the other and must be exclusive, so that if there is text in the box, the radiobutton gets deactivated.
Unfortunately I could not accomplish this so far and would be very grateful for any help.

Greetings from Germany,
Fenden
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago #95392 by tpartner
Can't you just use a radio question with "Other" enabled?



Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • fenden
  • fenden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 11 months ago #95394 by fenden
The textbox has to be above the radio button and should have no text in front.
The topic has been locked.
  • fenden
  • fenden's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 11 months ago #95398 by fenden
Is it possible to switch the other option with an option above? And to not give the other option a name/label?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago #95399 by holch
You can freely choose the text that is given to the other option. You might have to put at least a space, because otherwise it probably will use the default option.

I don't think that you can move the "other" option up in LS. But probably you can do something with Javascript. But I have no clue about that.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago #95414 by tpartner
1) Set up your survey to use JavaScript .

2) Add the following script to the source of the question. The script will hide The "Other" radio and label and move the text input to the top of the list.
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    // Identify this question
    var q1ID = '{QID}';
    var q1 = $('#question'+q1ID+'');
 
    // Hide the "Other" radio button and label
    $('.other-item input.radio, .other-item .answertext', q1).hide();
 
    // Move the "Other" row to the top
    $('.radio-list', q1).prepend($('.other-item', q1));
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
8 years 7 months ago #125710 by mafo
Is it also possible to move the text input to a specific position, say at position 3?
I think in this case the "prepend" in the following lines has to be changed.
Code:
// Move the "Other" row to the top
    $('.radio-list', q1).prepend($('.other-item', q1));
  });
Unfortunately, I don't know how it has to be changed. Can someone help?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #125715 by tpartner
Try this:

Code:
    // Insert the "Other" row after the second row
    $('li.answer-item:eq(1)', q1).after($('.other-item', q1));

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: mafo
The topic has been locked.
More
8 years 7 months ago #125801 by mafo
Thank you, that's what I need :).
Another question: Is it also possible to change the code of the "other" option such that, if it is chosen, there will be an 8 in my SPSS dataset?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #125806 by tpartner
No, not without hacking the core code. It's dead easy to recode it in SPSS though.

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: mafo
The topic has been locked.
More
8 years 7 months ago #125808 by mafo
Yes, it is really easy to recode. I was just curious whether it is feasible to do this step already in LimeSurvey.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose