- Posts: 10
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Remove the second and third text inputs $('input:text.form-control:gt(0)', thisQuestion).remove(); // Listener on the text input $('input:text.form-control', thisQuestion).on('keyup change', function(e) { var thisValue = $.trim($(this).val()); // Strip out non-numerics characters newValue = thisValue.replace(/\D/g,'').replace(/,/g,'').replace(/\./g,''); $(this).val(newValue); }); // Size and max characters for the text input $('input:text', thisQuestion).attr('size', 3).attr('maxlength', 3); // Suffix for the text input $('input:text', thisQuestion).css({ 'display': 'inline-block', 'margin-right': '0.5em' }) .after('Tag(e) pro Jahr'); // Render answers exclusive $('input:checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { var thisRow = $(this).closest('.checkbox-text-item'); $('.checkbox-text-item', thisQuestion).not(thisRow).each(function(i) { console.log(i); var thisCheckbox = $('input:checkbox', this); var thisText = $('input:text', this); $('input:text', this).val(''); $('input:hidden', this).val(''); $('input:checkbox', this).prop('checked', false); }); } }); }); </script>
$('input:text.form-control:gt(0)', thisQuestion).remove();
$('input:text.form-control:gt(0)', thisQuestion).remove();
$('input:text.form-control:gt(1)', thisQuestion).remove();
// Suffix for the text input $('input:text.form-control:eq(0)', thisQuestion).css({ 'display': 'inline-block', 'margin-right': '0.5em' }) .after('Suffix der 1. Teilfrage'); $('input:text.form-control:eq(1)', thisQuestion).css({ 'display': 'inline-block', 'margin-right': '0.5em' }) .after('Suffix der 2. Teilfrage');
No, it would be lt - www.w3schools.com/jquery/jquery_ref_selectors.aspSo an alternative to gt would be st for smaller than?
I have 5 options but only the 4th should display an input field
$('input:text.form-control:not(:eq(5))', thisQuestion).remove();