html - empty selectpicker javascript -


how empty selectpicker use of javascript? testing purposes have 2 selectpickers, html code:

 <select id="selectzvlntype" class="selectpicker show-tick" data-size="5" data-live-search="true" data-width="100%">     <option value="0" selected disabled>kies type zorgverlener</option>     <?php         $q = "select id_zvln_type, zvln_type              tbl_zvln_types              order zvln_type asc";         $r = mysqli_query($dbc, $q);         while($zvln_types = mysqli_fetch_assoc($r)) { ?>             <option value="<?php echo $zvln_types['id_zvln_type']; ?>"><?php echo $zvln_types['zvln_type']; ?></option>     <?php } ?>    </select> 

html code of second selectpicker:

 <select class="selectpicker show-tick" data-size="5" data-live-search="true" data-width="100%" id="selectzkh" onchange="ga('send', 'event', 'select choice', 'select zkh changed', this.options[this.selectedindex].value]);">     <option value="0" selected disabled>kies uw zorgverlener</option>     <?php         $q = "select id_zvln, zvln              tbl_zvln              order zvln asc";         $r = mysqli_query($dbc, $q);         while($zvln = mysqli_fetch_assoc($r)) { ?>             <option value="<?php echo $zvln['id_zvln']; ?>"><?php echo $zvln['zvln']; ?></option>     <?php } ?>  </select> 

my javascript code:

$(function() {    $('#selectzvlntype').on('change', function(){     //var selected = $(this).find("option:selected").val();     //alert(selected);     $('#selectzkh').empty();   });  }); 

the alert working, $('#selectzvlntype').on('change', function() working, .empty(); not..

any appreciated

selectpicker component not refresh automatically when manipulate dom element. need call $('#selectzkh').selectpicker("refresh") method make work.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -