感谢。
这是.NET的查询代码,在页面中执行正常,通过下拉列表选择,得到相关的数据;
现在我想改成:加个JS判断,如果所选择的值为“河南”或“陕西”就执行跳转如果是其它就跟以前一样执行正常查询
下面是原来.NET的代码
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                                    </asp:DropDownList>
下面JS是我东查西凑出来的就是说通过下拉列表选择能正常激活,也就是说跳转没问题但,以前的查询却执行不了,请问该如何来改啊
<script  type="text/javascript" language="JavaScript">
  <!--
function checkselect(objname){
    O = document.getElementById(objname);
    t = document.getElementById("output");

    var intvalue="";
    for(i=0;i<O.length;i++){           if(O.options[i].selected){

            intvalue+=O.options[i].value;            if (intvalue=="河南"){              window.open("http://www.cheyishang.com/cheyishang/hn.htm");
            return false;
                }else if (intvalue=="陕西"){
                window.open("http://www.cheyishang.com/cheyishang/sx.htm");
                return false;
                } else{
               onchange="javascript:setTimeout('__doPostBack(\'DropDownList1\',\'\')', 0)"//跟这句替换
               alert(intvalue);
                return true;
                 }


        }
    }
  </script>

解决方案 »

  1.   

    用js判断后还需要从新绑定啊。 这个是服务器控件 在写改变事件  DropDownList1_SelectedIndexChanged
      

  2.   

      protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {    定义一个变量 string name=DropDownList1.SelectedValue.ToString().
      if(name=="河南" || name=="陕西")
    {
       Response.Redirect("FrmContractAdd.aspx"?name="+ name+ "");//跳转的页面 name可作为参数
    }
        }
      

  3.   

    这个太简单了你在 DropDownList1_SelectedIndexChanged写你的代码不就行了吗  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
            {
                string s = DropDownList1.SelectedItem.Text;
                if (s == "河南" || s == "陕西")
                {
                    //跳转
                }
                else
                {
                    //不做处理
                }
            }