Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp string not working

Status
Not open for further replies.

SiJohn101

Technical User
Joined
Nov 13, 2001
Messages
13
Location
GB
I have the following checkbox on my site but it dosen't work, tried to ssolve it before but still having trouble.

this is the code from my first page

<P>Do you want to take pets with you?
<INPUT type=CHECKBOX name = "PETS" value = "Y">Yes<br>

This is the code from my second page

IF strPETS = "Y" THEN strSQLLOC = strSQLLOC & " AND fldPETS = 'Y' " ELSE strSQLLOC = strSQLLOC

Please help!!! The query is working because it is pasing over if field smoking has been checked but it won't write it to the page
 
you got your if then e line else statements all on one line

try this:
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements]] . . .
[Else
[elsestatements]]
End If
 
I have changed it to how you have said but still can't get it to work. Is this how you mean't

IF strPETS = "Y" THEN
strSQLLOC = strSQLLOC & " fldPETS = 'Y' "
ELSE strSQLLOC = strSQLLOC
End If
 
I've got to ask the obvious because of the way the post reads,

do you have strPets = request.form("pets") in your code?



Chris.

Indifference will be the downfall of mankind, but who cares?
 
I have this at the top of my page

strPETS = Request.QueryString ("PETS")

Here is the code for the whole page

<%@LANGUAGE="VBSCRIPT"%><%
Dim strLOCATION, IntLoop, strSQL(), strOCCUPANTS_NO, strSqlLOC, objConn, objRsLOC

strLOCATION = Request.QueryString ("LOCATION")
strOCCUPANTS_NO = Request.QueryString ("OCCUPANTS_NO")
strREQUIREMENT = Request.QueryString ("REQUIREMENT")
strBEDROOMS = Request.QueryString ("BEDROOMS")
strSMOKE = Request.QueryString ("SMOKING")
strPETS = Request.QueryString ("PETS")



strSqlLOC = "SELECT * from tblLOCATION, tblCOTTAGES where tblLOCATION.fldLOCATION_NO = tblCOTTAGES.fldLOCATION_NO AND fldOCCUPANTS_NO = " & strOCCUPANTS_NO

IF (strBEDROOMS<>"") THEN
SELECT CASE strREQUIREMENT
CASE "AL" strsqlLOC = strsqlLOC + "and fldBEDROOMS >=" & strBEDROOMS
CASE "EX" strsqlLOC = strsqlLOC + "and fldBEDROOMS =" & strBEDROOMS
END SELECT
END IF

IF strSmoke = "Y" THEN strSQLLOC = strSQLLOC & " AND fldSMOKING = 'Y' "
Else strSQLLOC = strSQLLOC

IF strPETS = "Y" THEN
strSQLLOC = strSQLLOC & " fldPETS = 'Y' "
ELSE strSQLLOC = strSQLLOC
End If


If Request.QueryString("LOCATION").Count = 0 Then
Response.Write "You have not selected any destinations. Please press the back button on your browser to try again."
ElseIf Request.QueryString("LOCATION").Count = 1 Then
ReDim strSQL(0)

If Request.QueryString("LOCATION") <> "All" Then
strSql(0) = Request.QueryString("LOCATION")(1)
strSqlLOC = strSqlLOC & " and tblCOTTAGES.fldLOCATION_NO = (SELECT fldLOCATION_NO from tblLOCATION where fldLOCATION_NO = " & strSQL(0) & ")"
End If
Else

ReDim strSQL (Request.QueryString("LOCATION").Count -1 )

strSqlLOC = strSqlLOC & "and tblCOTTAGES.fldLOCATION_NO = any (SELECT fldLOCATION_NO FROM tblLOCATION WHERE"
For IntLoop = 0 To (Request.QueryString("LOCATION").Count - 1)

strSQL(IntLoop) = Request.QueryString("LOCATION")(IntLoop + 1)

strSqlLOC = strSqlLOC & " fldLOCATION_NO = " & strSQL(Intloop) & ""

If IntLoop <> (Request.QueryString("LOCATION").Count - 1) Then

strSqlLOC = strSqlLOC & " or "
End If
Next
strSqlLOC = strSqlLOC & ")"
End If




Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "TPVORCDSN"
Set objRs=objConn.Execute(strsqlLOC)
%>






<P><FONT color="#009933">
<table>
<tr>
<TD><FONT color="#009933">PROP NO</TD>
<TD><FONT color="#009933">LOCATION</TD>
<TD><FONT color="#009933">OCCUPANTS</TD>
<TD><FONT color="#009933">BEDROOMS</TD>
<TD><FONT color="#009933">PETS</TD>
<TD><FONT color="#009933">SMOKING</TD>
<TD><FONT color="#009933">MORE INFO</TD>
</TR>

<%
Do While Not (objRs.EOF)
%>
<TR>
<TD><FONT color="#009933"><%=objRs("fldPROP_NO")%></TD>
<TD><FONT color="#009933"><%=objRs("fldLOCATION")%></TD>
<TD><FONT color="#009933"><%=objRs("fldOCCUPANTS_NO")%></TD>
<TD><FONT color="#009933"><%=objRs("fldBEDROOMS")%></TD>
<TD><FONT color="#009933"><%=objRs("fldPETS")%></TD>
<TD><FONT color="#009933"><%=objRs("fldSMOKING")%></TD>
<td><FONT color="#009933"><A HREF="test3.asp? NO =<%=objRs("fldProp_NO")%> & PB =<%=objRs("fldPriceband")%>">More Info</A></td>


</TR>
<%objRs.MoveNext
Loop



ObjRS.Close
Set objRS=Nothing
ObjConn.Close
Set objConn=Nothing
%>





</body>



</HTML>
 
without doing any code testing shouldn't this

Code:
 strSQLLOC & " fldPETS = 'Y'

be this?

Code:
 strSQLLOC & " AND fldPETS = 'Y'




Chris.

Indifference will be the downfall of mankind, but who cares?
 
Cheers i've looked at it that many times and changed that many things that i've probaley had it working for the past few days but missed that simple thing. Cheers you've saved my sanity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top