English 中文(简体)
我如何通过额外的参数去格凯里·自治领域?
原标题:How do I pass an extra parameter to Jquery Autocomplete field?

I m 以我的形式使用JQuery Autocomplete。

基本表格从我的数据库中选择产品。 这一工作是巨大的,但我要进一步加以发展,只有从某种焦炭编码装运的产品才能返回。 我看上下背书。 我只需要找到最佳途径,把警钟编码传入这一文字。

这就是我的形式。

<form>

<select id="zipcode">

<option value="2000">2000</option>
<option value="3000">3000</option>
<option value="4000">4000</option>

</select>

<input type="text" id="product"/>

<input type="submit"/>

</form>

这里是《联邦法典》:

$("#product").autocomplete
({
     source:"product_auto_complete.php?postcode=" + $( #zipcode ).val() +"&",
     minLength: 2,
     select: function(event, ui){

                             //action

                                 }
});

该法典在一定程度上发挥作用。 但是,只有回归第一种焦普编码值,而实际上不管其价值如何。 我猜测的是,LURL的原始来源是放在页数上,而不是在选定的菜单发生变化时。 是否有办法解决这一问题? 总体而言,能否在一米之后取得成果?

最佳回答

您需要对<代码>源代码/代码>采用不同的方法。 呼吁:

$("#product").autocomplete({
  source: function(request, response) {
    $.getJSON("product_auto_complete.php", { postcode: $( #zipcode ).val() }, 
              response);
  },
  minLength: 2,
  select: function(event, ui){
    //action
  }
});

这种格式允许你在“上”时,而不是“在“<>上>时”。

问题回答

这对男子来说并非复杂:

$(document).ready(function() {
src =  http://domain.com/index.php ;

// Load the cities straight from the server, passing the country as an extra param
$("#city_id").autocomplete({
    source: function(request, response) {
        $.ajax({
            url: src,
            dataType: "json",
            data: {
                term : request.term,
                country_id : $("#country_id").val()
            },
            success: function(data) {
                response(data);
            }
        });
    },
    min_length: 3,
    delay: 300
});
});
jQuery("#whatJob").autocomplete(ajaxURL,{
    width: 260,
    matchContains: true,
    selectFirst: false,
    minChars: 2,
    extraParams: {  //to pass extra parameter in ajax file.
        "auto_dealer": "yes",
    },
});

我认为,你在考虑“网络”(“产品”)要求时是正确的。 也许你可以向选定的菜单分配交换手:

$("#zipcode").change(resetAutocomplete);

<代码>#product autocomplete()呼唤并创建新的产品。

function resetAutocomplete() {
    $("#product").autocomplete("destroy");
    $("#product").autocomplete({
         source:"product_auto_complete.php?postcode=" + $( #zipcode ).val(),
         minLength: 2,
         select: function(event, ui){... }
    });
}

您不妨要求您的重新编造书(Autocomplete)成为一小小条mar子——例如,如果单体编码实际上不同于最后价值的话——以拯救少数服务器电话。

这对我来说是这样。 活动<代码>search:

jQuery( #Distribuidor_provincia_nombre ).autocomplete({
     minLength :0,
     search :function(event,ui){
        var newUrl="/conf/general/provincias?pais="+$("#Distribuidor_pais_id").val();
        $(this).autocomplete("option","source",newUrl)
    },
     source :[]
});

希望这将有助于:

$("#txt_venuename").autocomplete({
    source: function(request, response) {
    $.getJSON( <?php echo base_url(); ?>admin/venue/venues_autocomplete , 
        { 
            user_id: <?php echo $user_param_id; ?>, 
            term: request.term 
        }, 
      response);
    },
    minLength: 3,
    select: function (a, b) {            
        var selected_venue_id = b.item.v_id;
        var selected_venue_name = b.item.label;            
        $("#h_venueid").val(selected_venue_id);
        console.log(selected_venue_id);            
    }
});

缺省词将由新的参数清单取代,因此,你需要再次增加。

$( #product ).setOptions({
    extraParams: {
        extra_parameter_name_to_send: function(){
            return $("#source_of_extra_parameter_name").val();
        }
    }
})
$( #txtCropname ).autocomplete( Handler/CropSearch.ashx , {
    extraParams: {
        test:  new 
    }
});




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...