- Posts: 88
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var q1ID = '{QID}'; var thisQuestion = $('#question'+q1ID); //Identify the inputs var activeInputs = $('tr[id^="javatbd"]:not(:last) .answer-item:nth-child(2) input:text.form-control', thisQuestion); var totalInput = $('tr[id^="javatbd"]:last .answer-item:nth-child(2) input:text.form-control', thisQuestion); // Render the text input in the last row readonly $('tr[id^="javatbd"]:last .answer-item:nth-child(2) input:text', thisQuestion).prop('readonly', true); // Listener on the text inputs in first coloumn, except last row $(activeInputs).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); // Load the total into the last row var total = 0; $(activeInputs).each(function(i) { total = total + Number($(this).val()); }); $(totalInput).val(total).trigger('change') }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.