Hi i want to manage data on drop-down menu using Ajax.
Databse Fields:
1.id
2.name
3.department
myDesgin.php
<select id="id"></select>
<select id="name"></select>
<select id="department"></select>
1.If i selected one drop-down menu want to change another drop-downs depend on selected value using Ajax.
2.Is there any code available, if i select one drop-down it go to another child window and display data as in table format(like report) using Ajax.
Thanks in Advance.
Please give me example code, because i am beginner to ajax , most welcome if someone provide explanation with code(for ajax).
Yes, check following jquery ajax code. In this example, if you change "Department" then it will populate the listing of "Name" dropdown.
$(document).on("change", '#department', function(e) {
var department = $(this).val();
$.ajax({
type: "POST",
data: {department: department},
url: 'admin/users/get_name_list.php',
dataType: 'json',
success: function(json) {
var $el = $("#name");
$el.empty(); // remove old options
$el.append($("<option></option>")
.attr("value", '').text('Please Select'));
$.each(json, function(value, key) {
$el.append($("<option></option>")
.attr("value", value).text(key));
});
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With