Load select when selecting date

3

I have to load a select with different data, according to the date chosen, and I do not know how to achieve this.

The only thing that occurred to me was to occupy onchange in the input where it is shown the time, but it does not work. I read there that onchange does not work very well if the input does not have the "focus". Any help is welcome, greetings.

This is the view of the fields:

Pressing the calendar button opens this

Then we select the date and it stays that way, and at this point I need to load a select when choosing a date.

    
asked by Luis Pavez 08.11.2016 в 14:17
source

2 answers

1

Without your code it is a bit difficult to answer, however, based on the screenshots, it seems that you are working in two browser windows. It would be advisable that this window that you launch as popup was a floating layer (one, for example) in the same document, in order to be able to communicate with the form field without problems.

This is how it works, for example the jquery ui datepicker plugin .

    
answered by 28.11.2016 в 11:45
1

Here is an example with jQuery (the easiest way to work) on how to change a select when changing the date field:

$(document).ready(function (){
 $("#fecha").on("change",function () {
  $("#opciones").html("\
   <option>opcion a</option>\
   <option>opcion b</option>\
   <option>opcion c</option>");
 });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="fecha" type="date">
<select id="opciones">
<option>opcion 1</option>
<option>opcion 2</option>
<option>opcion 3</option>
</select>
    
answered by 10.04.2017 в 04:38