i want to display all table list from a database in drop down menu and allow user to select table name. when user selects table name i want to show all the data. html file is like this
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$.ajax({url:"home.php?id=1",
success:function(result){
$("#div1").html(result);
}});
$("#dropdown").change(function(){
alert("list item selected");
$.ajax({url:"home.php?id=2&tablename="+tableForm.tableLists.value,
success:function(result){
$("#div2").html(result);
}});
});
});
</script>
</head>
<body>
<button value="add" >
<form name="tableForm">
<div id="div1"></div>
</form>
</button>
<br><hr>
<div id="div2"></div>
</body>
this page runs okay and displays a list of alltable name belonging to database. but when i select a value from the dropdown list it doesnt even alert “list item selected” messsage. what to do to make it work ??
here is the an image of dropdown list

It looks like the dropdown box is dynamically loaded into the page, so you must bind the function to the dynamically added element using
.on():