Welcome to the LimeSurvey Community Forum

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

Can put some value to text-style question by click radio button?

More
9 years 1 month ago #116370 by cnsla
Can put some value to text-style question by click radio button?

Like below.
I tried it, but didn't work.

<input type="radio" class="text empty" id="answer{SGQ}SQ001" name="{SGQ}SQ001" value="1" />
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 month ago #116384 by tpartner
Sorry, don't understand the question.

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: cnsla
The topic has been locked.
More
9 years 1 month ago #116388 by cnsla
Due to huge survey size, I gave up using 'array'. (php error happens...)
I hope to make some workaround in "multiple short texts" question type.
I want to make some radio buttons 'linked' to text input box
(i.e. when clink radio button 1, put "1" to SQ 001 text input box, when click radio button 2, erase "1" and put "2" to SQ001 text input box)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 month ago #116432 by tpartner
Placing something like this in the source of the multiple-text question should load the first two inputs. Of course, you will need to replace "input.my-radio-class" and "input.another-radio-class" with the proper selectors.

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Load first text input
    $('input.my-radio-class').click(function(e) {
      $('input.text:eq(0)', thisQuestion).val($(this).attr('value')); 
    });
 
    // Load second text input
    $('input.another-radio-class').click(function(e) {
      $('input.text:eq(2)', thisQuestion).val($(this).attr('value')); 
    });
    });
</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.

Lime-years ahead

Online-surveys for every purse and purpose