Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery自动完成未获取更新值_Javascript_Jquery - Fatal编程技术网

Javascript jQuery自动完成未获取更新值

Javascript jQuery自动完成未获取更新值,javascript,jquery,Javascript,Jquery,我试图获取文本框中的值及其工作情况,但主要问题是,当我从选择框更新供应商时,current\u vendor变量会更改其值,但在自动完成函数中,源URL会保留current\u vendor的旧值,即0,而不是新值,我不知道我在做什么错误或丢失这是我的代码 $(document).ready(function(){ var current_vendor = 0; $("select[name=txtvendor]").change(function

我试图获取文本框中的值及其工作情况,但主要问题是,当我从选择框更新供应商时,
current\u vendor
变量会更改其值,但在自动完成函数中,源URL会保留
current\u 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);
            }
        }
});
});

您需要调用
autocommfunction()
函数来更新
current\u vendor
变量的值尝试此代码它将解决问题

$("select[name=txtvendor]").change(function() {
vendor_code = this.value;
$('.selectpicker').selectpicker('refresh');
AutoComFunction();
}).change();