Skip to content Skip to sidebar Skip to footer

Cascading Dropdowns From Mysql With Javascript And Php

EDIT: Solution at the bottom of this first entry. I've been scouring SO for a good day or two now and am not having any luck coming up with getting my dynamic drop downs working. I

Solution 1:

You should probably use Ajax to load the php script every time the first select changes.

Adapted from sending http request with ajax each time select box is changed :

I tried adapting the answer to your question but I can't really test it:

$("#company").live('change',function() 
{
    var selectVal = $('#company :selected').val();


    var $terms = $('#terms').html('');

    $.ajax({                                      
      url: 'customertermsdropdownquery.php',                         
      data: "id="+selectVal,                                                     
      dataType: 'GET',                
      success: function(data)         
      {

              $terms.append(data);

      } 
    });

});

Post a Comment for "Cascading Dropdowns From Mysql With Javascript And Php"