经典ASP多重复选框单击重定向到具有值的同一页面

时间:2013-06-20 06:44:50

标签: asp-classic

我正在根据复选框值进行一些搜索。如果我选择一个复选框,我需要一个值,如果我选择第二个复选框也需要2个复选框值。

目前我的代码带有单选按钮。需要将它们转换为具有多个选项的复选框。根据请求值,它将传递给存储过程。

<% if request("view")="Key CIA Initiative" then %>
<input type="radio" checked="checked" 
   onclick="javascript:document.location='Index.asp?view=Key CIA Initiative'" />
<input type="radio" onclick="javascript:document.location='Index.asp?view=High'" />
<input type="radio"  onclick="javascript:document.location='Index.asp'" />

<% else %>

<% if request("view")="High" then %>
<input type="radio"  onclick="javascript:document.location='Index.asp?view=Key            
 Initiative'" />
<input type="radio" checked="checked" onclick="javascript:document.location='Index.asp?
view=High'" /> 
<input type="radio"  onclick="javascript:document.location='Index.asp'" />
<% else %>
<input type="radio"  onclick="javascript:document.location='Index.asp?view=Key CIA 
Initiative'" />
<input type="radio"  onclick="javascript:document.location='Index.asp?view=High'" />
<input type="radio"  onclick="javascript:document.location='Index.asp'" /> 
<%end if%>
<%end if%>       

单击单选按钮时,它会重定向到带有请求值的同一页面,然后我将传递给存储过程

 If request("view")="Key CIA Initiative" Then
  strSQL = "Exec sp_get_Project_list 'Key CIA Initiative' "
 Else
 If  request("view")= "High" then
  strSQL="Exec sp_get_Project_list 'High' "
 Else 
  strSQL="Exec sp_get_Project_list "
 end if
 end if

1 个答案:

答案 0 :(得分:0)

你必须做这样的事情:

<%
Response.write "Request(view)="& request("view") & "<br />"
'Now, if request("view") has nultiple values, How are you going to call the sp? 
'pass both values to it?
If Trim(Request("view"))<>"" Then

    If InStr(Request("view"),"All")<>0 Then
        strSQL="Exec sp_get_Project_list"
    Else
    strSQL = "Exec sp_get_Project_list '"& Request("view") &"'"
    End if
Response.write "strSQL ="& strSQL & "<br />"
End If
%>
<form>
<input type="checkbox" name="view" value="Key CIA Initiative" <% if InStr(request("view"),"Key CIA Initiative")>0 then %> checked="checked"<%End If%> />Key CIA Initiative <br/>
<input type="checkbox" name="view" value="High" <%if InStr(request("view"),"High")>0 then %> checked="checked"<%End If%>  />High<br/>
<input type="checkbox" name="view" value="All" <%if InStr(request("view"),"All")>0 then %> checked="checked"<%End If%> />All <br/>
<input type="submit">
</form>