Hi I am using jquery to get data from mysql. It works wonderfully but I need it to update a select box when another select box is changed. Here is what I have for jquery:
<I'm not sure why you are using live
- is the original select sometimes replaced via AJAX as well? It may be, however, that you simply need to clear the original values first since you are only appending the new ones.
$("#airports").live('change',function()
{
var selectVal = $('#airports :selected').val();
alert(selectVal);
var $output = $('#output').html('');
$.ajax({
url: 'tras-hotels.php',
data: "n="+selectVal,
dataType: 'json',
success: function(data)
{
$.each(data, function(key,value) {
$output.append("<option value='"+value.id+"'>"+value.hotel+"</option>");
});
}
});
});