Forum Moderators: open
I need a link to have 2 search criteria/ conditions. For instance, page.asp?UserSkills=Webdeveloper&AccountType=Seller
which I have coded as:
<a href='search.asp?UserSkills=" & Trim(Request("UserSkills")) &"&AccountType=" & Trim(Request("AccountType")) &"'>
the problem I'm having is that when the AccountType is 'Buyer' I need the URL to search for 'Seller' and when the AccountType is 'Leasing' I need the URL to search for 'Renting'
I have created a number of variables to use
<% Dim varSeller, varBuyer, varLease, varRent
varSeller = "Seller"
varBuyer = "varBuyer"
varLease = "varLease"
varRent = "varRent"
%>
now I need some sort of an 'if' statement to make it work.
So if the current account type on this page is 'Seller' search for 'buyer' in the search.asp page and vice versa then I have to cram it into the URL.
I wonder can anyone help me here? I hope I explained this properly.
<%
Dim myQueryAccountTypeSelect Case Trim(LCase(Request("AccountType")))
Case "buyer"
myQueryAccountType = "seller"Case "seller"
myQueryAccountType = "buyer"Case "leasing"
myQueryAccountType = "renting"Case "renting"
myQueryAccountType = "leasing"End Select
Response.Write "<a href='search.asp?UserSkills=" & Trim(Request("UserSkills")) &"&AccountType=" & myQueryAccountType &"'>"
%>
I need to merge both of these pieces of code into one...
<%
Dim myQueryAccountType
Select Case Trim(LCase(Request("AccountType")))
Case "buyer"
myQueryAccountType = "seller"
Case "seller"
myQueryAccountType = "buyer"
Case "leasing"
myQueryAccountType = "renting"
Case "renting"
myQueryAccountType = "leasing"
End Select
Response.Write "<a href='search.asp?UserSkills=" & Trim(Request("UserSkills")) &"&AccountType=" & myQueryAccountType &"'>"
%>
<%
Dim myKeywords
myKeywords = "music, dance, chat, property"
Dim myKeywordArray
myKeywordArray = Split(myKeywords, ",")
For i = 0 to UBound(myKeywordArray)
response.write "<a href='/Search.asp?query=" & Trim(myKeywordArray(i)) & "'>" & Trim(myKeywordArray(i)) & "</a>, "
Next
%>
I had a go at doing it like this but I'm a bit of a novice at arrays. I suppose if these codes were chemicals I would have blown myself up eh? I wonder could anyone help me solve my conundrum?
<%
Dim myKeywords
myKeywords = Rsusers("UserSkills")
Dim myKeywordArray
myKeywordArray = Split(Rsusers("UserSkills"), ",")
Dim myQueryAccountType
Select Case Trim(LCase(Request("AccountType")))
Case "buyer"
myQueryAccountType = "seller"
Case "seller"
myQueryAccountType = "buyer"
Case "leasing"
myQueryAccountType = "renting"
Case "renting"
myQueryAccountType = "leasing"
End Select
For i = 0 to UBound(myKeywordArray)
response.write "<a href='search.asp?UserSkills=" & Trim(myKeywordArray(i)) &"&AccountType=" & myQueryAccountType &"'>" & Trim(myKeywordArray(i)) & "</a>, "
%>
Thanks for any help offered.
Kev.
...
For i = 0 to UBound(myKeywordArray)response.write "<a href='search.asp?UserSkills=" & Trim(myKeywordArray(i)) &"&AccountType=" & myQueryAccountType &"'>" & Trim(myKeywordArray(i)) & "</a>, "
Next
%>
Also, you can scrap the first two lines as they are unnecessary, because you are splitting the recordset directly
Dim myKeywords
myKeywords = Rsusers("UserSkills")
search.asp?UserSkills=drums&AccountType=
instead of:
search.asp?UserSkills=drums&AccountType=seller
I have the script written exactly as it is in the above message:
...
For i = 0 to UBound(myKeywordArray)
response.write "<a href='search.asp?UserSkills=" & Trim(myKeywordArray(i)) &"&AccountType=" & myQueryAccountType &"'>" & Trim(myKeywordArray(i)) & "</a>, "
Next
%>
I wonder could anyone help me? If I get this sorted out I have 4 more pages that I can fix up in 10 mins as they all have the same problem :(
Thanks for any help offered.
Kevin
Case "renting"
myQueryAccountType = "leasing"
Case Else
myQueryAccountType = "UnexpectedAccountType"
End Select
What do you mean by 'try outputting the given value with Response.Write(Request("AccountType")) to see what it contains' do you mean put Response.Write(Request("UnexpectedAccountType")) into the page to see what it shows?
What do you mean by 'try outputting the given value with Response.Write(Request("AccountType")) to see what it contains' do you mean put Response.Write(Request("UnexpectedAccountType")) into the page to see what it shows?
I think we have our wires crossed somehow, I assumed that you were querying the value of AccountType to generate a new URL?
So if the URL or AccountType the database (aren't they both the same?) is Seller the AccountType = Buyer
I hope I'm not confusing you.
So, on the search page itself, have something like the following:
<%
Select Case LCase(Request.QueryString("AccountType"))
Case "buyer"
' Search for Sellers
Case "leasing"
' Search for renters
Case Else
' Do something else
End Select
%>
(I would also consider storing the AccountType in a session variable instead of constantly passing it from page to page)