[英]jQuery Autocomplete not getting updated value
我試圖讓文本框和其工作的價值,但主要的問題是,當我更新從選擇框中的供應商current_vendor
變量改變其價值,但在自動完成功能的源URL保留的舊值current_vendor
是0
,而不是新我不知道我做錯了什么或缺少的是我的代碼
$(document).ready(function(){
var current_vendor = 0;
$("select[name=txtvendor]").change(function() {
var current_vendor = $(this).find("option:selected").val();
});
$("input#ProdDescription").autocomplete({
source: "includes/modProducts/search-products.php?viewVendor="+current_vendor,
minLength: 1,
select: function (event, ui) {
var item = ui.item;
if(item) {
$(this).closest('.row').find('.txtchassis').val(item.ChassisNo);
$(this).closest('.row').find('.txtdescription').val(item.BikeDescription);
$(this).closest('.row').find('.txtprice').val(item.SellingAmount);
$(this).closest('.row').find('.txtbikeid').val(item.BikeID);
$(this).closest('.row').find('.txtcostprice').val(item.CostPrice);
$(this).closest('.row').find('.txtcolorcode').val(item.ColorCode);
}
}
});
});
您需要調用AutoComFunction()
函數來更新current_vendor
變量的值,請嘗試使用此代碼來解決問題
$("select[name=txtvendor]").change(function() {
vendor_code = this.value;
$('.selectpicker').selectpicker('refresh');
AutoComFunction();
}).change();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.