Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Default text input in array-multi-flexi-text

Default text input in array-multi-flexi-text 6 years 3 weeks ago #52542

  • joteczek
  • joteczek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Hello! I've problem with designing questions.

I've 1.90+ Build 9459 version. I have a array-multi-flexi-text mandatory question with 2 columns (City, Number of people in City) and 5 rows (1, 2, 3, 4, 5). I want to have a default answer in all of the input text fields in this question (for example 'NONE').

My question is: how can I do this? I've looked into Default values in array questions topic and there is a solution but only for checked/unchecked radio buttons.

Can anyone help me?
The administrator has disabled public write access.

Default text input in array-multi-flexi-text 6 years 3 weeks ago #52555

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
There is no setting for default answers in array-multi-flexi-text inputs but you can use JavaScript to cheat.

Set up your survey to use JavaScript and place the following script in the source of the array question or the group description. Replace "QQ" (line 5) with the ID of the array question and modify the default value (line 6) as necessary.
<script type="text/javascript" charset="utf-8">
 
    $(document).ready(function() {
 
        var qID = QQ;
        var  defaultVal = 'None';
 
        // Loop text inputs and load default value
        $('#question'+qID+' input[type="text"]').each(function(i) {
 
            if (!$(this).val()) {
                $(this).val(defaultVal);
            }
        });
 
    });
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Default text input in array-multi-flexi-text 6 years 3 weeks ago #52556

  • joteczek
  • joteczek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Thank you! It's working!
The administrator has disabled public write access.

Default text input in array-multi-flexi-text 6 years 3 weeks ago #52573

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6029
  • Thank you received: 373
  • Karma: 260
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
The administrator has disabled public write access.
Time to create page: 0.213 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form