当有人在下拉列表中选择项目时,我正在使用 jquery 刷新页面。但随后它会返回默认选择。
(这可以防止用户使用两个下拉菜单进行搜索。)
如何获取下拉菜单以保存在页面刷新时选择的项目?
下面的代码:
<%@ LANGUAGE="VBSCRIPT" %>
<%
pagetitle="Contractor Details"
%>
<!--#INCLUDE VIRTUAL="/_lib/include/header.htm"-->
<!--#INCLUDE VIRTUAL="/_lib/include/menu.htm"-->
<script>
$(document).ready(function() {
$("#abn,#cat").change(function () {
this.form.submit();
})
});
</script>
<div class="twoColumnRow">
<div class="twoColumnContent">
<p class="breadCrm"><a href="/index.htm">Home</a> <span>></span> <a href="/tools/index.htm">Tools of the Trade</a> <span>></span> <a href="/tools/finance/index.htm">Finance and Purchasing</a><span>></span> <a href="/tools/finance/procurement/index.htm">Procurement and Contracts information</a></p>
<div class="contentPad">
<!-- Start of main content -->
<p class="imageRight"> </p>
<h1><%=pagetitle%></h1>
<%
Dim connectString, connect, conDB, sconDB, con, scon, src_abn, src_cat
connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
src_abn = Request.QueryString("abn")
src_cat = Request.QueryString("cat")
set connect = Server.CreateObject("ADODB.connection")
connect.open connectString
if src_abn = "all" and src_cat = "all" then
conDB = "SELECT * FROM cont.csv"
elseif src_abn = "all" then
conDB = "SELECT * FROM cont.csv WHERE " & src_cat & " = 'Yes'"
elseif src_cat = "all" then
conDB = "SELECT * FROM cont.csv WHERE ucase(abn) LIKE ucase('%"+src_abn+"%')"
else
conDB = " SELECT * FROM cont.csv WHERE " & src_cat & " = 'Yes' AND ucase(abn) LIKE ucase('%"+src_abn+"%')"
end if
sconDB = "SELECT * FROM cont.csv"
set con = connect.execute(conDB)
set scon = connect.execute(sconDB)
%>
<h2>Search results</h2><hr />
<% if not con.BOF then %>
<div style="margin-top:1em">
<form action="dbresults.htm" method="get">
<p>Company name:<br/>
<select id="abn" name="abn">
<option label="All companies" value="all"></option>
<% while (NOT scon.EOF) %>
<option label="<%=scon("legal")%>" value="<%=scon("abn")%>"></option>
<%scon.MoveNext()
Wend %>
</select>
</p>
<p>Categories for Creative Design:<br/>
<select id="cat" name="cat">
<option class="group" label="All categories" value="all"></option>
<option class="group" label="Strategic brand, marketing and communications advice" value="a"></option>
<option class="group" label="Graphic design and layout" value="b"></option>
<option class="group" label="Forms design" value="c"></option>
<option class="group" label="Web design and development" value="d"></option>
<option class="group" label="Authoring services" value="e"></option>
<option class="group" label="Editorial services" value="f"></option>
<option class="group" label="Translation services" value="g"></option>
<option class="group" label="Photography and film services" value="h"></option>
<option class="group" label="Scanning and digitisation services" value="i"></option>
<option class="group" label="Multimedia editing services" value="j"></option>
</select>
</p>
<input type="submit" value="Search" />
</form>
<br /><hr />
<table style="font-size:.9em;" class="contentTable">
<tr>
<th>ABN:</th>
<th>Company Name:</td>
</tr>
<% con.Movefirst() %>
<% while (NOT con.EOF) %>
<tr>
<td><%=con("abn")%></th>
<td><a href="dbcomp.htm?abn=<%=con("abn")%>&cat=all"><%=con("legal")%></a></td>
</tr>
<%
con.MoveNext()
Wend
%>
</table>
</div>
<% else %>
<% scon.Movefirst() %>
<form action="dbresults.htm" method="get">
<p>Company name:<br/>
<select name="abn">
<option label="All companies" value="all"></option>
<% while (NOT scon.EOF) %>
<option label="<%=scon("legal")%>" value="<%=scon("abn")%>"></option>
<%scon.MoveNext()
Wend %>
</select>
</p>
<p>Categories for Creative Design:<br/>
<select name="cat">
<option label="All categories" value="all"></option>
<option label="Strategic brand, marketing and communications advice" value="a"></option>
<option label="Graphic design and layout" value="b"></option>
<option label="Forms design" value="c"></option>
<option label="Web design and development" value="d"></option>
<option label="Authoring services" value="e"></option>
<option label="Editorial services" value="f"></option>
<option label="Translation services" value="g"></option>
<option label="Photography and film services" value="h"></option>
<option label="Scanning and digitisation services" value="i"></option>
<option label="Multimedia editing services" value="j"></option>
</select>
</p>
<input type="submit" value="Search" />
</form>
<br /><hr />
<p>No records match your query.</p>
<p><a href="dbtest.htm">Return to search page</a></p>
<%
end if
con.close
%>
<!-- End of main content -->
</div> <!-- end contentPad div -->
</div> <!-- end twocolumncontent div -->
<div class="twoColumnLinks">
<!--<div class="relatedLinks">
<h3>Related Links</h3>
<ul>
<li><a href="/index.htm">Related link 1</a></li>
</ul>
</div>--> <!-- end relatedlinks div -->
<!--#INCLUDE VIRTUAL="/_lib/include/quicklinks.htm"-->
<!--#INCLUDE VIRTUAL="/_lib/include/mylinks.htm"-->
</div> <!-- end twocolumnlinks div -->
</div> <!-- end twocolumnrow div -->
<!--#INCLUDE VIRTUAL="/_lib/include/footer.htm"-->