Dynamic select option

Asked

Viewed 64 times

0

I have a input:text with datepicker.

Selecting the date, it is sent via ajax and returned the values in Json. All right so far, it works perfectly here on the desktop using Chrome.

But in iphone that is the most important these results are not changed dynamically in select option.

Follow the code used:

$(function() {
    $('input[name="data"]').datepicker({
        startDate: '<?php echo date('d-m-Y'); ?>',
        format: 'dd-mm-yyyy',
        daysOfWeekDisabled: '0,6',
        language: 'pt-BR',
        todayHighlight: true,
        autoclose: true,
    }).on('change', function(){

        var select_element = document.getElementById('hora');
        select_element.innerHTML = "";
        /// Exemplo simples do resultado em Json.
        var data = {'0':'22:00','1':'22:30','2':'23:00','3':'23:30'};
            $.each(data, function(key, valor) {
                var opt = document.createElement('option');
                opt.value = valor;
                opt.innerHTML = valor;
                select_element.appendChild(opt);
            });
        $('.datepicker').hide();

    });
});
  • You are using Momentjs?

  • You can mount a jsFiddle that plays the problem so we can test on the mobile?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.