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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If request.Querystring("var1") = "" or request.querystring(& 1

Status
Not open for further replies.

mattboyslim

Programmer
Aug 31, 2005
30
US
I have a page where I'm displaying certain things depending on the querystring.

If I only use one request.querystring, then it works, but if I add an OR statement to show if either one of 2 cases is applicable, then it doesn't work.

OR
*If contact = anything, then the rating system should not display
*If contactcomplete = anything, then the rating system should not display

My code is here:
WORKS to not display the "rating system":
Code:
-------------------------
<% If request.QueryString("contact") = "" Then %>
<div style="padding-top:50px">Rate <%=(rs_attraction.Fields.Item("f_name").Value)%>:</div>
<% END IF %>
-------------------------
DOES NOT WORK
Displays the rating system:
Code:
--------------------------
<% If request.QueryString("contact") = "" or request.QueryString("contactcomplete") = "" Then %>
<div style="padding-top:50px">Rate <%=(rs_attraction.Fields.Item("f_name").Value)%>:</div>
<% END IF %>
--------------------------
Surely it is possible to accomplish this task. I just need the rating system to NOT show if the querystring contains either "contact" or "contactcomplete".

Thanks,
Matt
 
ok. guess that's TT formatting it. nevermind

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Maybe I'm confused on what you are trying to accomplish but your logic but it works fine for what you explained.



[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
I thought my logic was fine too, but unfortunately it doesn't appear to work. Here is a page that displays the "Ratings System" at the bottom when it shouldn't.


Here is the code:
===========================
<% If request.QueryString("contact") = "" or request.QueryString("contactcomplete") = "" Then %>
<div style="padding-top:50px">Rate <%=(rs_attraction.Fields.Item("f_name").Value)%></div>
<% END IF %>
==================
 
That should be displaying the line
Code:
<div style="padding-top:50px">Rate <%=(rs_attraction.Fields.Item("f_name").Value)%></div>
because one condition has been found True.


[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
OK, so I need the "Ratings System" to NOT show if EITHER condition is true, how do I do that?
 
Maybe you're getting mixed up on the OR operator (or I'm mixed up as usual)

If either of those conditions are found True then your final value is True meaning the line will be written out. Both must be found to be False in order to skip the write

or it would have to be
Code:
[URL unfurl="true"]http://localhost/test.asp?contact=3&contactcomplete=3[/URL]
to not write the line

any other condition would write it out.
Code:
[URL unfurl="true"]http://localhost/test.asp?contact=3&contactcomplete=[/URL]
[URL unfurl="true"]http://localhost/test.asp?contact=&contactcomplete=[/URL]
[URL unfurl="true"]http://localhost/test.asp?contact=&contactcomplete=4[/URL]
[URL unfurl="true"]http://localhost/test.asp?[/URL]

The only other way to not show them would be to take the querystring out all together as
Code:
[URL unfurl="true"]http://localhost/test.asp[/URL]

even this would be found True though
Code:
[URL unfurl="true"]http://localhost/test.asp?[/URL]

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
OK, now I'm thoroughly confused. So you appear to be correct:
DOES NOT DISPLAY RATINGS

DOES DISPLAY RATINGS

DOES DISPLAY RATINGS

DOES DISPLAY RATINGS


So how can I go about making it show if the querystring ONLY contains ID, and noting else? My brain hurts, it's time for a cigarette.
 
Code:
<% If NOT (request.QueryString("contact") = "" OR request.QueryString("contactcomplete") = "") Then %>
<div style="padding-top:50px">Rate <%="test"%>:</div>
<% END IF %>

My brain hurts, it's time for a cigarette.

Don't feel bad. I shouldn't have looked at a True/False = True False/False = True and everything else = True without getting done with my first cup of coffee for the morning

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
At this point in your conditioning I would suggest going to a more stable way of doing it with the form collection. Meaning POST your data across instead of using QueryString values. You can then rely on the objects being there more than if a user changes the URL on you and causes errors and have an object available to test values instead of the object being Nothing. You can use hidden fields and set them based on what condition has been met on the first page.

Otherwise you will need to test if the contact or contactcomplete querystring are there along with the ID. Then based on several different combinations showing them what you need. That can get extremely messy and hard to maintain not to mention not stable at all when it comes to clear ability of it being altered.

You are already relying on JavaScript for the rating system so just add a function to the rating.js file to set hidden values upon submitting the form.





[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
ahh...coffee is good.

So you could do something like this example
Code:
<html>
<head>
<script language="javascript">
function setForm() {
	myFrm.contact.value = "";
	myFrm.contactcomplete.value = "";
	myFrm.id.value = "";
	myFrm.submitted.value = "submitted";
	myFrm.submit();
}
</script>
</head>
<body>
<%
If Request.Form("submitted") = "" Then
	%>
	<form name="myFrm" method="post" action="test.asp">
	<input type="hidden" name="contact">
	<input type="hidden" name="contactcomplete">
	<input type="hidden" name="id">
	<input type="hidden" name="submitted">
	Something......

	<input type="button" value="submit" onclick="setForm();">
	</form>
<%
Else

	If Request.Form("contact") <> "" AND Request.Form("contactcomplete") <> "" Then
	%>
		<div style="padding-top:50px">Rate <%="f_name"%>:</div>
	<%
	ElseIf Request.Form("id") <> "" Then
	%>
		<div style="padding-top:50px">Rate <%="f_name"%>:</div>
	<%
	End If
End If
%>
</body>
</html>

now you can change that all around to condition differently. Depends on what and where id comes from (and the others really). Will there always be an id? I'm assuming yes.

If not you could change it up and add "AND Request.Form("id")" to the first condition check.

Really the point is you shouldn't rely on QueryStrings for what seems to be an important task. Other than that I don't think you've posted enough information on the possibilities of what can come across and what may not come across in order for us to build a valid conditional statement with the operators asking for the right things. I could be way off and if so let us know what happens to get the strings or form objects over in the first place

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Haha, well following the quote in your signature, I appear to have made it work with your code:

<% If (request.QueryString("contact") = "" AND request.QueryString("contactcomplete") = "") Then %>

When I hit this page, I get the ratings:

When I click the "Email" button, to bring up the contact form, the ratings do not show (this is good):

After the form has been filled out, the ratings do not show (this is good).

Thanks for all the help so far. Right now, the web site is simply a "proof of concept" to demo to customers, so hopefully everything will work out and we can go through cleaning up and speeding up code.

I'm posting another question on counting the number of records in a recordset as soon as I hit "Submit" here.
 
I'll guess cursor and lock type related

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top