- Posts: 26
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var qID = {QID}; // Define the select element (dropdown) var select1 = '<select class="insertedSelect"> \ <option value="">-- Please Choose --</option> \ <option value="Program 1">Program 1</option> \ <option value="Program 2">Program 2</option> \ <option value="Program 3">Program 3</option> \ <option value="Program 4">Program 4</option> \ </select>'; // Hide the text inputs $('#question'+qID+' .answer_cell_004 input[type="text"]').hide().parent().hide(); // Insert the select elements $('#question'+qID+' .answer_cell_004').append(select1); // Initially select an option if the question has already been answered $('#question'+qID+' .answer_cell_004 input[type="text"]').each(function(i){ if($(this).val()) { $(this).closest('td').find('.insertedSelect').val($(this).val()); } }); // Listener on the dropdowns - insert selected values into hidden text input $('.insertedSelect').change(function() { $(this).closest('td').find('input[type="text"]').val($(this).val()); }); }); </script>
$('#question'+qID+' .answer_cell_004 input[type="text"]').hide().parent().hide();
$('#question'+qID+' .answer_cell_004 input[type="text"]').hide();
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var qID = {QID}; // Define the select element (dropdown) var select1 = '<select class="insertedSelect">\ <option value="">-- Please Choose --</option>\ <option value="Nuevo">Nuevo</option>\ <option value="Reparado">Reparado</option>\ <option value="Deteriorado">Deteriorado</option>\ <option value="Inservible">Inservible</option>\ </select>'; // Hide the text inputs $('#question'+qID+' .answer_cell_004 input[type="text"]').hide(); // Insert the select elements $('#question'+qID+' .answer_cell_004').append(select1); // Initially select an option if the question has already been answered $('#question'+qID+' .answer_cell_004 input[type="text"]').each(function(i){ if($(this).val()) { $(this).closest('td').find('.insertedSelect').val($(this).val()); } }); // Listener on the dropdowns - insert selected values into hidden text input $('.insertedSelect').change(function() { $(this).closest('td').find('input[type="text"]').val($(this).val()); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#question{QID} .answer_cell_X1 option[value=1]').text('No recurro'); $('#question{QID} .answer_cell_X1 option[value=2]').text('Arocena Gustavo'); $('#question{QID} .answer_cell_X1 option[value=3]').text('Aspra Manuel'); $('#question{QID} .answer_cell_X1 option[value=4]').text('Bravo Ricardo'); $('#question{QID} .answer_cell_X1 option[value=5]').text('Zalazar Martin'); $('#question{QID} .answer_cell_X2 option[value=1]').text('No recurro'); $('#question{QID} .answer_cell_X2 option[value=2]').text('Bravo Ricardo'); $('#question{QID} .answer_cell_X2 option[value=3]').text('Fernandez Flavio'); $('#question{QID} .answer_cell_X2 option[value=4]').text('Zalazar Martin'); $('#question{QID} .answer_cell_X2 option[value=5]').remove(); }); </script>