当我在文本框上调用Java Script Funtion时,下拉列表索引更改不会触发 [英] Dropdownlist Index Change Does Not Fire When I Call Java Script Funtion on textbox

查看:74
本文介绍了当我在文本框上调用Java Script Funtion时,下拉列表索引更改不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是



My code is

<div class="col-md-2" id="dvabc"  runat="server">
<asp:DropDownList runat="server" AutoPostBack="true" ID="ddlabc" CssClass="form-control input-sm" OnSelectedIndexChanged="ddlStateMain_SelectedIndexChanged">
</asp:DropDownList>
</div>

<asp:TextBox runat="server" ID="txtSearch" placeholder="FPS" CssClass="form-control input-sm" />
 <div class="col-md-1">
               <asp:Button ID="btnView" runat="server" Text="View"

                                CausesValidation="true" class="btn btn-primary" OnClick="btnView_Click" />
                        </div>




<link href="jquery-ui-1.8.21.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.min.js" />
<script type="text/javascript" src="jquery-ui.min.js" />
<script type="text/javascript">

    $(document).ready(function () {

        SearchText();
    });

    function SearchText() {
        var abc = $('#<%=ddlabc.ClientID%>').text;
        var alloc = abc;
        var tehsil = "001";
        $('[id*=txtSearch]').autocomplete(
        {

            source: function (request, response) {

                $.ajax(
               {

                   type: "POST",
                   contentType: "application/json; charset=utf-8",
                   url: "frmPaymentByFPS.aspx/GetAutoSearchFPS",
                   data: "{'ddlAllocationOrderNo':'" + alloc + "','Tahsil':'" + tehsil + "','FairPriceShop':'" + extractLast(request.term) + "'}",

                   dataType: "json",
                   success: function (data) {

                       response(data.d);
                   },
                   error: function (result) {
                       alert("Error");
                   }
               });
            },
            focus: function () {
                // prevent value inserted on focus
                return false;
            },
            select: function (event, ui) {
                var terms = split(this.value);
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push(ui.item.value);
                // add placeholder to get the comma-and-space at the end
                terms.push("");
                this.value = terms.join(", ");
                return false;
            }
        });
        $("#txtSearch").bind("keydown", function (event) {
            if (event.keyCode === $.ui.keyCode.TAB &&
            $(this).data("autocomplete").menu.active) {
                event.preventDefault();
            }
        })
        function split(val) {
            return val.split(/,\s*/);
        }
        function extractLast(term) {
            return split(term).pop();
        }
    }

</script>



这个java脚本正在用于自动搜索。

当我更改ddlabc的索引时,它不起作用。

如果我也有按钮,我点击按钮,然后按钮和ddlabc索引一个接一个地改变。



在vs2010中,它运行正常。



我有很多下拉,文本框和一个按钮。

如果单击按钮它会被触发但更改选择的下拉不会如果我改变了选择,那么我必须点击按钮进行选择更改。

除按钮点击事件之外的任何事件都不会触发。





我发现问题来自母版页或bootstrap。


This java script is working for auto search.
When I Change index of ddlabc it does not work.
If I have button also and I click button then button and ddlabc index change both fired one by one.

In vs2010, it is working fine.

I have many drop down, text box and one button.
If click button it is fired but change selection of drop down does not fired.
If I change selection then i have to click button for selection change.
Any Event except button click event does not fire.


I found the thing is that prob from master page or bootstrap.

推荐答案

document )。ready( function (){

SearchText();
});

function SearchText(){
var abc =
(document).ready(function () { SearchText(); }); function SearchText() { var abc =


' #<%= ddlabc.ClientID%>')文本;
var alloc = abc;
var tehsil = 001;
('#<%=ddlabc.ClientID%>').text; var alloc = abc; var tehsil = "001";


' [id * = txtSearch]')。autocomplete(
{

source: function (request,response){
('[id*=txtSearch]').autocomplete( { source: function (request, response) {


这篇关于当我在文本框上调用Java Script Funtion时,下拉列表索引更改不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆