i have two dropdown getting value from database:
Table_Buildings
|id|---|building_name|
Table_Floors
|id|---|Floor_name|---|building(Foreign key to table_Buildings)|
and in my form
Dropdown: building)
$db->setQuery("SELECT buildings.building_name, floors.id FROM buildings INNER JOIN floors ON buildings.id=floors.id"
Dropdown: floor)
$db->setQuery("SELECT floor_name, id FROM floors");
For filtering my dropdown i want to use this script:
<script type="text/javascript">
var xhr;
jQuery(function($) {
$('#filter_building').change(function(){
var filterBuilding = $('#filter_building').val();
if (xhr && xhr.abort) {xhr.abort();xhr=false;}
xhr = jQuery.ajax( {
url: 'index.php',
data: 'option=com_mycomponent',
success: function(data){
jQuery('#filter_building').replaceWith(data);
} }
);
});
});
</script>
but somewhere is wrong and its not working