我有一个DropDownList,其中包含从SQL Server数据库填充的文本字段和值字段。我希望用户选择Value Field并输入" country:"低于"术语:请求术语"在JavaScript中。感谢这里的每位成员提供帮助。
DropDownList:
<asp:DropDownList ID="CountryDDL" runat="server" Height="100%"></asp:DropDownList>
JavaScript的:
<script>
$(function () {
$("[id$=OriginLocationTextBox]").autocomplete({
source: function (request, response) {
$.ajax({
url: "https://api.sandbox.amadeus.com/v1.2/airports/autocomplete",
dataType: "json",
data: {
apikey: "API KEY",
term: request.term,
country:
},
success: function (data) {
response(data);
}
});
},
minLength: 3,
});
});
</script>
答案 0 :(得分:2)
如果你不需要通过.net但是ajax收集数据,你可以这样做:
的DropDownList:
<asp:DropDownList ID="CountryDDL" runat="server" Height="100%" onchange="requestfunc(this.options[this.selectedIndex].value)"></asp:DropDownList>
JavaScript的:
<script>
function requestfunc(val){
$(function () {
$("[id$=OriginLocationTextBox]").autocomplete({
source: function (request, response) {
$.ajax({
url: "https://api.sandbox.amadeus.com/v1.2/airports/autocomplete",
dataType: "json",
data: {
apikey: "API KEY",
term: request.term,
country: val
},
success: function (data) {
response(data);
}
});
},
minLength: 3,
});
});
}
</script>