我添加了三个单选按钮,我希望这些按钮对显示在 asp 经典页面上的数据列表进行排序。数据是从数据库中提取的,下面的代码是我到目前为止完成此排序的代码,但我无法完成它。首先,我想获得一个 onSelect 提交选项,它将刷新页面或列表(刷新列表会更好),并根据用户选择的顺序对列表进行相应的排序。
单选按钮的代码
<form method=get action=featuredvehicle.asp>
<input type="radio" name="sort" value="make">Make<br>
<input type="radio" name="sort" value="model">Model<br>
<input type="radio" name="sort" value="model_year">Model Year
</form>
从单选按钮获取值的代码
<%
Dim strSQL1
Dim OrderList
OrderList = Request.QueryString("sort")
If OrderList = "" Then
strSQL1 = "SELECT * FROM featuredvehicles ORDER by make, model, model_year asc;"
ElseIf OrderList = make THEN
strSQL1 = "SELECT * FROM featuredvehicles ORDER by make, model, model_year asc;"
ElseIf OrderList = model THEN
strSQL1 = "SELECT * FROM featuredvehicles ORDER by model, model, model_year asc;"
rsLogbook.Open strSQL1, adoCon
ElseIf OrderList = model_year THEN
strSQL1 = "SELECT * FROM featuredvehicles ORDER by model_year, make, model asc;"
END IF
rsLogbook.Open strSQL1, adoCon
%>
从数据库中列出列表的代码。
<blockquote>
<% rsLogbook.Movefirst
do while not rsLogbook.EOF %>
<p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Tahoma" size="2" color="#5A87B4">
<img border="0" src="images/obdkey_icon.gif"><a href="http://websitelink.com?vehicle=<%Response.Write(rsLogbook("id"))%>">
<%=rsLogbook("make")%> <%=rsLogbook("model")%> <%=rsLogbook("model_year")%></a>
<%Response.Write("<br />") %>
<% rsLogbook.MoveNext%></font></p>
<%loop %>
</blockquote>
再一次,我想做的是
- 单选按钮有一个选择提交选项
- 获取从单选按钮中选择的值并相应地对列表进行排序(通过刷新列表或任何其他必要的方式)