navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

A little help with an If - Then statement

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> A little help with an If - Then statement
Page: [1]
 
shmcadoo

 

Posts: 33
Joined: 11/21/2003
Status: offline

 
A little help with an If - Then statement - 5/14/2004 12:43:41   
I am passing parameters through a hyperlink from a results page to a page that I want to compare the parameters and then redirect. These parameters include two numbers. I am trying to do this.

IF 1stvalue => 2ndvalue THEN response.write ("session is full") Else show form.

:)I am not able to put it all together to complete this task. Thanks for your help.
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 12:58:46   
First, are you sure the parameters are making it through? If so, you should see them in the URL. Assuming they are, then something like this:

In the body just before the form, paste this:

<%
If Value1 >= Value2 Then
Response.write "Session is full."
Else
%>

Then after your form, enter:

<%End If%>

That should work.

< Message edited by betheball -- 5/14/2004 10:59:16 >


_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to shmcadoo)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 13:01:48   
quote:

IF 1stvalue => 2ndvalue THEN response.write ("session is full") Else show form


Probably something like:
<%
IF 1stvalue => 2ndvalue THEN
response.write ("session is full")
ELSE%>
code for form
<%END IF%>

What do you currently have? If the values are numeric, they should compare OK?

EDIT: Slow typing finger (notice the singular 'finger'):)

< Message edited by rdouglass -- 5/14/2004 13:02:38 >


_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to shmcadoo)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 13:10:52   
But look how beautifully those two code snippets match. :)

If I am getting to where I think like you on this stuff, then I am feeling pretty good about myself. :)

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rdouglass)
shmcadoo

 

Posts: 33
Joined: 11/21/2003
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 13:43:22   
Unfortunately I don't think like either of you yet!

I pasted this before any code:
<%
IF CntOfAttendees=> Seats THEN
response.write ("session is full")
ELSE%>


and this after all code:
<%END IF%>


No matter what the values are the page displays "Session is Full" and never displays the form. The values are passing into the URL for this page.

Is there a format for the values that I need to use?

(in reply to BeTheBall)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 13:51:21   
Try this in place of the first snippet above.

<%
Dim CntofAttendees, Seats
CntofAttendees=CInt(Request.QueryString("CntofAttendees"))
Seats=CInt(Request.QueryString("Seats"))
IF CntOfAttendees=> Seats THEN
response.write ("session is full")
ELSE%>

Also, I am not positive you can put the snippet at the very beginning of the page. I would suggest you put it just before the <form> tag.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to shmcadoo)
shmcadoo

 

Posts: 33
Joined: 11/21/2003
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 13:51:50   
The CntOfAttendees value comes from a COUNT in db and the seats value is from a table and is a number.

(in reply to shmcadoo)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 13:53:29   
quote:

<%
IF CntOfAttendees=> Seats THEN
response.write ("session is full")
ELSE%>


<%
IF CntOfAttendees >= Seats THEN
response.write ("session is full")
ELSE%>

Duane did have it correct.:) If that still does not give you the results you expect, debug it with a response.write:

<%
IF CntOfAttendees >= Seats THEN
response.write("CntOfAttendees = " & CntOfAttendees &" - Seats = " & Seats & "<br>")
response.write ("session is full")
ELSE%>

EDIT: Notice the greaterthan or equal two sign order....

< Message edited by rdouglass -- 5/14/2004 13:55:02 >


_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to shmcadoo)
shmcadoo

 

Posts: 33
Joined: 11/21/2003
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 14:10:20   
BAM!:)It works!

I used this code:
quote:

<%
Dim CntofAttendees, Seats
CntofAttendees=CInt(Request.QueryString("CntofAttendees"))
Seats=CInt(Request.QueryString("Seats"))
IF CntOfAttendees=> Seats THEN
response.write ("session is full")
ELSE%>


Now for some FYI on my part. Do I use the Dim and request.querystring each time I do If thens like this? What other times are these useful?

Thanks for your expertise....
Scot

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: A little help with an If - Then statement - 5/14/2004 14:25:02   
Generally speaking, if you're going to use VBScript variables outside the current code block (the <% and %>), then you should DIM them. If not (and IIRC) the variables only apply to the local block.

It's also good practice to define all variables. I have had circumstances where I've used the same variable name twice. By DIMming them, VBScript will tell me that I've already defined it and hence avoid the problem.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to shmcadoo)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> A little help with an If - Then statement
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts