- Posts: 37
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript"> $(document).ready(function(){ // Recupera la lista delle regioni dal campo token personalizzato var regioniString = '{TOKEN:regioni}'; var regioni = regioniString.split(";"); // Rimuove tutte le righe tranne la prima $('#question{QID} .subquestion-list tr').slice(1).remove(); // Clona la prima riga come template var templateRow = $('#question{QID} .subquestion-list tr:first').clone(); // Pulisce la riga template templateRow.find('th').text(''); templateRow.find('input[type=radio]').prop('checked', false); // Aggiunge le righe con le regioni reali for (var i = 0; i < regioni.length; i++) { var newRow = templateRow.clone(); newRow.find('th').text(regioni[i]); // Cambia il nome degli input per mantenerli univoci newRow.find('input').each(function(){ var oldName = $(this).attr('name'); var newName = oldName.replace(/X[0-9]+X[0-9]+/, 'X{QID}X' + (i+1)); $(this).attr('name', newName); }); $('#question{QID} .subquestion-list').append(newRow); } // Rimuove la riga di esempio $('#question{QID} .subquestion-list tr:first').remove(); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.