change on select with javascript

Solutions on MaxInterview for change on select with javascript by the best coders in the world

showing results for - "change on select with javascript"
Viktoria
24 Nov 2016
1$("#select1").change(function() {
2  if ($(this).data('options') === undefined) {
3    /*Taking an array of all options-2 and kind of embedding it on the select1*/
4    $(this).data('options', $('#select2 option').clone());
5  }
6  var id = $(this).val();
7  var options = $(this).data('options').filter('[value=' + id + ']');
8  $('#select2').html(options);
9});