- Posts: 48
- Thank you received: 3
Ask the community, share ideas, and connect with other LimeSurvey users!
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.
// Define the select element (dropdown) var prov1 = '<select id="prov1" class="form-control">\ <option value="">-- ... --</option>\ <option value="1">Gobierno</option>\ <option value="2">Colegio profesional</option>\ <option value="3">Otros</option>\ </select>'; var prov2 = '<select id="prov2" class="form-control">\ <option value="">-- ... --</option>\ <option value="2">2 años</option>\ <option value="3">3 años</option>\ <option value="4">4 años</option>\ <option value="5">5 años</option>\ <option value="6">6 años</option>\ <option value="7">7 años</option>\ </select>';
// Hide the text input $('#question'+qID+' .question-item:eq(3) input[type="text"]').hide(); $('#question'+qID+' .question-item:eq(4) input[type="text"]').hide(); // Insert the select elements if($('#question'+qID+' .question-item:eq(3) select').length == 0) { $('#question'+qID+' .question-item:eq(3) input[type="text"]').before(prov1); } if($('#question'+qID+' .question-item:eq(4) select').length == 0) { $('#question'+qID+' .question-item:eq(4) input[type="text"]').before(prov2); }
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var rootPath = location.pathname.split('index.php')[0]; // Identify this question var thisQuestion = $('#question{QID}'); $('head').append('<link rel="stylesheet" href="'+rootPath+'assets/packages/bootstrap/plugins/datetimepicker/build/css/bootstrap-datetimepicker.min.css" type="text/css" />'); $.getScript(rootPath+'assets/packages/bootstrap/plugins/datetimepicker/build/js/bootstrap-datetimepicker.min.js') .done(function(script, textStatus) { // Insert the date-time-pickers $('.answer-item:nth-child(3) input:text', thisQuestion).each(function(i) { $(this).addClass('date-control date datetimepicker') .wrap('<div class="inserted-date-wrapper input-group date date-timepicker-group" />') .after('<div class="input-group-addon datetimepicker-addon btn btn-primary">\ <i class="fa fa-calendar" aria-hidden="true"></i><span class="sr-only"></span>\ </div>'); $(this).datetimepicker({ widgetParent: $(this).parent(), useCurrent:false, allowInputToggle: true, format: 'MM.YYYY' }); }); }) .fail(function( jqxhr, settings, exception ) { console.log(exception); }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.