- Posts: 3
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
10 years 11 months ago #95388
by fenden
Radio button and textbox combined in one question was created 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
10 years 11 months ago #95392
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Radio button and textbox combined in one question
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- fenden
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
10 years 11 months ago #95394
by fenden
Replied by fenden on topic Radio button and textbox combined in one question
The textbox has to be above the radio button and should have no text in front.
The topic has been locked.
- fenden
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
10 years 11 months ago #95398
by fenden
Replied by fenden on topic Radio button and textbox combined in one question
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
- Online
- LimeSurvey Community Team
Less
More
- Posts: 11644
- Thank you received: 2738
10 years 11 months ago #95399
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Radio button and textbox combined in one question
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 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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
10 years 11 months ago #95414
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Radio button and textbox combined in one question
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.
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.
- mafo
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 0
8 years 7 months ago #125710
by mafo
Replied by mafo on topic Radio button and textbox combined in one question
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.
Unfortunately, I don't know how it has to be changed. Can someone help?
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)); });
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 7 months ago #125715
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Radio button and textbox combined in one question
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.
- mafo
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 0
8 years 7 months ago #125801
by mafo
Replied by mafo on topic Radio button and textbox combined in one question
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?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
8 years 7 months ago #125806
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Radio button and textbox combined in one question
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.
- mafo
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 0
8 years 7 months ago #125808
by mafo
Replied by mafo on topic Radio button and textbox combined in one question
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.