C
C
cyberlain2016-06-29 15:09:06
JavaScript
cyberlain, 2016-06-29 15:09:06

There is such a plugin for such selects that take data from json?

d733ed8808a5444e86421bf2d933569b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2016-06-29
@Menlod

<script type="text/javascript" charset="utf-8">
$(function(){
  $("select#city").change(function(){
    $.getJSON("/select.php",{id: $(this).val(), ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#myselect").html(options);
    })
  })
})
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question