感谢。
这是.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>
这是.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>
{ 定义一个变量 string name=DropDownList1.SelectedValue.ToString().
if(name=="河南" || name=="陕西")
{
Response.Redirect("FrmContractAdd.aspx"?name="+ name+ "");//跳转的页面 name可作为参数
}
}
{
string s = DropDownList1.SelectedItem.Text;
if (s == "河南" || s == "陕西")
{
//跳转
}
else
{
//不做处理
}
}