当查询条件既有文本框又有超级链接怎样实现联合查询?
我们知道点击超链接后不会有viewstate,所以不会像文本框传值那样后台可以通过textbox1.text获取查询条件,只能用js获取值
方法一:通过js获取文本框的值,通过链接地址传到后台
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function addHrefPara(obj)
{
var para = document.getElementById("InputText").value;// 获取文本框中的值
var href = obj.getAttribute("href");// 获取超链接HREF属性值
var hrefNew = href + para;
obj.setAttribute("href",hrefNew);
}
</SCRIPT>
</head>
<body>
<input name="InputText" type="text" id="InputText">
<a href="1.html?word=" onclick="addHrefPara(this)" target="_blank">谢谢大家帮助</a>
</body>
</html>
方法二:
<script>
function TZ(dsid) {
var m = document.getElementById("txtXQ").value;
var n = document.getElementById("DropDownList1");
var index = n.selectedIndex;
var value = n.options[index].value;
if (value != 3) {
var url = "List.aspx?1=1&dsid=" + dsid + "&status=" + value;
}
else {
var url = "List.aspx?1=1&dsid=" + dsid;
}
if (m != "") {
url += "&dwmc=" + m;
}
var date = new Date();
location.href = url + "&clear=" + date;
}
</script>
<div>
<a href="javascript:TZ('<%=ds1.Tables[0].Rows[i]["code"]%>')"> </a>
</div>