比如 dropdownlist里面有三个值  a、b、c  第一次选值的时候不提示,如果现在有个值是a,当我在选值b时,则提示是否改变其值?

解决方案 »

  1.   

    $("#DropDownListID").bind("change", function() {
       // 当选择改变是发生
    });
      

  2.   

    这是我的jsfunction OnCurrentYearProfitAccoutRefChangedHandler(grid, ev)
    {
    var dto = ev.value;    // 得到控件
        var comboCtl=document.getElementById("CurrentYearProfitAccout");
        // 得到控件值
        var dto=comboCtl.value; 
        if(dto.length!=0)
        {
       //在这里面写  改怎么写啊
        }    var grid=this.getGrid();
        grid.endEdit(); 
        for(var i=0;i<grid.rowCount;i++)
        {
            grid.setCellValue(i,"ProfitAccount_Code",dto.Code);
            //grid.setCellValue(i,"ProfitAccount",dto.Name);
            //grid.setCellValue(i,"idprofitAccount",dto.ID);
            grid.setRefValue(grid.getCol("ProfitAccount"), dto, i);
            
        }
      
    }
      

  3.   

    <script language="javascript"> 
    function Change() 
    {
        var vValue=document.all('DropDownList1').value;
        alert(vValue);
    }
    </script>    
        
     <asp:DropDownList ID="DropDownList1" runat="server" Width="253px" AutoPostBack="false" onchange="Change();" Height="20px" >
                <asp:ListItem Value="a">a</asp:ListItem>
                <asp:ListItem Value="b">b</asp:ListItem>
                <asp:ListItem Value="b">c</asp:ListItem>
    </asp:DropDownList>
      

  4.   

    开始的时候change事件绑定到一个方法a,在方法a里将dropdownlist的事件绑定解除,再绑定到方法b,方法b里做你要多提示。这样第一次就不提示了
      

  5.   

    dropdownList就是select. <select id="Select1" onchange="change(this);">
           <option value="1">1</option>
            <option value="2">2</option>
        </select><script>
    var index=0;
    function change(src)
    {
        if(window.confirm())
        {
            index=src.selectedIndex;
        }   
        else
        {
            src.selectedIndex=index;
        } 
    }
        </script>
      

  6.   

    jquery:
    $("#DropDownListID").change(function() {
      // 事件处理
    });
      

  7.   

    额,看来也不用这么麻烦了,页面定义一个的flag变量,事件执行的时候,判断flag,看是否要提示,若是则提示,否则把flag改掉
      

  8.   

    dropdownList就是select.<asp:DropDownList ID="DropDownList1" runat="server" Width="253px" AutoPostBack="false" onchange="change(this);" Height="20px" >
      <asp:ListItem Value="a">a</asp:ListItem>
      <asp:ListItem Value="b">b</asp:ListItem>
      <asp:ListItem Value="b">c</asp:ListItem>
    </asp:DropDownList><script>
    var index=0;
    function change(src)
    {
      if(window.confirm("是否改变"))
      {
      index=src.selectedIndex;
      }   
      else
      {
      src.selectedIndex=index;
      }  
    }
      </script>
      

  9.   

    jquery:
    $("#DropDownListID").change(function() {
      // 事件处理
    });
      

  10.   

    $(function() {
       // 初始化
       var iCount = 0;
       var iSelValue = $("#DropDownListID").val();   // 绑定事件
       $("#DropDownListID").bind("change", function() {
           if (iCount > 0 && iSelValue != $(this).val()) {
               // 第二次改变了
           }       iCount++;
           iSelValue = $(this).val();
       });
    });
      

  11.   

     this.CurrentYearProfitAccout.OnRefChanged = "OnCurrentYearProfitAccoutRefChangedHandler";
    这就是我的事件
      

  12.   

    你说错了
    实际上不一样的 因为没有ONCHANGE这个方法
    实验下行吗 
      

  13.   

    手写onchange,应该没问题吧,<select>是不是有onchange?
      

  14.   

    function OnCurrentYearProfitAccoutRefChangedHandler(grid, ev)
    {
    var dto = ev.value;  // 得到控件
      var comboCtl=document.getElementById("CurrentYearProfitAccout");
      // 得到控件值
      var dto=comboCtl.value;  
      if(dto.length!=0)
      {
      //在这里面写 改怎么写啊
      }  var grid=this.getGrid();
      grid.endEdit();  
      for(var i=0;i<grid.rowCount;i++)
      {
      grid.setCellValue(i,"ProfitAccount_Code",dto.Code);
      //grid.setCellValue(i,"ProfitAccount",dto.Name);
      //grid.setCellValue(i,"idprofitAccount",dto.ID);
      grid.setRefValue(grid.getCol("ProfitAccount"), dto, i);
        
      }
       
    }
    其他的都不要管了   就在这里面写   。
      

  15.   

    <SELECT id=select 
                                  onchange=window.open(this.options[this.selectedIndex].value,'','') 
                                  size=1 name=select>  <%GetDaoH("4");%>
      

  16.   

    <script>
    var flag=false;
    </script>if(dto.length!=0)
      {
      
    if(flag){
    alert('改了!');
    }else{
    flag=true;
    }  }
      

  17.   

    都说了  没有change事件  晕死 都不看 
      

  18.   


    你这个flag  什么意思?直接在html页面定义  然后在js引用    怎么引用啊  能引用的到吗?这就是我的控件 
           <cc1:RefComboBox ID="CurrentYearProfitAccout" 
                             DropDownPanelID="DropDownComboList1" 
                             runat="server"
                             AutoLoadData="true"
                             DropDownStyle="DropDownGrid" 
                             RefDataSource="AccountDTO" 
                             AllowEdit="true" 
                             AllowInput="true" 
                             AllowAdd="true" 
                             RefObject="AccountDTO"  
                             RefPage="~/CommonPage/RefPage.aspx"
                             ControlType="RefComboBox"
                             />   没有change事件
      

  19.   

    你只是不能单击出来而已,但是你如果写了onchange事件,是不会报错的,因为DropDownList在编译的时候就是将编译为Select的