$(document).ready(function () {
$("#dropdownlist").change(function () {
alert("Doet het!");
});
});
Alleen nu moet die via ajax een request gestuurd worden naar het ashx bestand met het geselecteerde item. weet iemand hoe je dit doet?
ik heb al iets als dit:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Dropdownlist</title>
<script src="beheer/Scripts/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function () {
$("#dropdownlist").change(function () {
alert($("#dropdownlist").val(showUser));
var data = new FormData();
data.append("name", $("#dropdownlist").val());
var options = {};
options.url = "dropdownlist.ashx";
options.type = "POST";
options.data = data;
options.contentType = false;
options.processData = false;
options.success = function (result) {
alert(result);
};
options.error = function (err) { alert(err.statusText); };
$.ajax(options);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select name="test" id="dropdownlist" change="showUser(this.value)">
<option value="">~~~</option>
<option value="BMW">BMW</option>
<option value="Audi">Audi</option>
</select>
</div>
</form>
</body>
</html>
Klopt natuurlijk niks van.