Размещать динамические даты и времени из html модальных в javascript - PullRequest
0 голосов
/ 09 октября 2019

у меня есть сценарий на фотографии вложения

enter image description here

код такой:

   <fieldset>
   <legend>test form - <a href="#" class='button red remove'>delete</a></legend>
                            <p>
                            <label for="data_inizio">Date:</label>
                            <input id="data_inizio" type="date" name="data_inizio[]">
                            <input type="time" value="09:00" step="900" name="ore_minuti_inizio[]" id="ore_minuti_inizio">
                            <input type="time" value="10:00" step="900" name="ore_minuti_fine[]" id="ore_minuti_fine">
                            </p>
                        </fieldset>

, когда я нажимаю на«добавить форму» следующий javascript добавить строку или «удалить» удалить строку, это код:

 <script>
//define template
var template = $('#sections .section:first').clone();

//define counter
var sectionsCount = 1;

//add new section
$('body').on('click', '.addsection', function() {

//increment
sectionsCount++;

//loop through each input
var section = template.clone().find(':input').each(function(){

    //set id to store the updated section number
    var newId = this.id + sectionsCount;

    //update for label
    $(this).prev().attr('for', newId);

    //update id - THIS CAUSES JqueryUI Datepicker to bug, also you shouldn't use numerical only IDs
    //this.id = newId;

}).end()

//inject new section
.appendTo('#sections');
//initialize datePicker on last name=date[] element in HTML DOM
$("input[name='date[]']").last().datepicker();
return false;
});
//init original datePicker in HTML DOM
$("input[name='date[]']").last().datepicker();
//remove section
$('#sections').on('click', '.remove', function() {
//fade out section
$(this).parent().fadeOut(300, function(){
    //remove parent element (main section)
    $(this).parent().parent().empty();
    return false;
});
return false;
});

</script>

теперь, если возможно, что я могу сделать, чтобы получить все время даты в javascript при нажатиикнопка "insertisci"? хотел бы создать массив дат ... что-то вроде этого

<script type="text/javascript">

        $('#btnInsertEventoo').click(function(){
            var data_inizio[] = $('#data_inizio[]').val();
            console.log(data_inizio);

        });
    </script>

кто-нибудь может мне помочь? простите за английский я итальянец:)

...