Welcome to the LimeSurvey Community Forum

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

Text field within text

  • Joffm
  • Joffm's Avatar Topic Author
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #205023 by Joffm
Text field within text was created by Joffm
Like this?


Change all question types to "short free text".
In the script exchange all "select" to "input".
In the css part of the script set the desired width.
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready',function(){
    var thisSelect = $('#question{QID} input[id^="answer"]:eq(0)');
    var secondSelect = $('#question{QID}').nextAll('[id^="question"]:eq(0)').find('input[id^="answer"]:eq(0)');
    var thirdSelect = $('#question{QID}').nextAll('[id^="question"]:eq(1)').find('input[id^="answer"]:eq(0)');
 
    // Move the first dropdown
    $('#question{QID} .inserted-dropdown:eq(0)').append(thisSelect);
    // Move the second dropdown
    $('#question{QID} .inserted-dropdown:eq(1)').append(secondSelect);
    // Move the second dropdown
    $('#question{QID} .inserted-dropdown:eq(2)').append(thirdSelect);
 
    // Hide the next question
    $('#question{QID}').nextAll('[id^="question"]:eq(0)').hide();
    // Hide the next question
    $('#question{QID}').nextAll('[id^="question"]:eq(1)').hide();
  });
</script>
<style type="text/css">#question{QID} input {
                display: inline-block;
                margin: 0 0 0 -0.25em;
                width: 17%;
                height: auto;
                padding: 0;
            }
</style>

I did not change the class "inserted-dropdown" though it isn't a dropdown anymore.
Doesn't matter.

And fine tuning is up to you.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose