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

Microsoft MVP

 

"if then" help

 
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 >> "if then" help
Page: [1]
 
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
"if then" help - 12/4/2003 16:15:41   
i'm trying to say .. if field name contains anything then display this text and link to this field name. But I'm not as familiar with this stuff as I want to be, hence I sak for help!

I have:

<%
if FP_FieldVal(fp_rs,"fieldname") = "" then 
response.write "<a href="<%=FP_FieldLink(fp_rs,"fieldname?www.leisure-ideas.com" target="_blank"><font size="1" face="Verdana">Visit Web Site</font></a>"
else 
'do something for NO
end if
%>


_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning
BeTheBall

 

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

 
RE: "if then" help - 12/4/2003 19:20:05   
Change this line:

if FP_FieldVal(fp_rs,"fieldname") = "" then

to this

if FP_FieldVal(fp_rs,"fieldname") <> "" then

Not sure what you are trying to do in the response.write. Where exactly do you want to redirect to?

_____________________________

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 Eli)
Richard Dudley

 

Posts: 668
Joined: 8/22/2002
From: Butler, PA
Status: offline

 
RE: "if then" help - 12/4/2003 21:18:49   
Try this:

quote:

<%
if FP_FieldVal(fp_rs,"fieldname") = "" then
response.write("<a href=" & FP_FieldLink(fp_rs,"fieldname?www.leisure-ideas.com" target="_blank"> & "<font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>


Your main traps here are the double quotes and the & (concatenation) operator. You also had the <%= (reponse.write) operator inside of a response.write.

_____________________________

I need to change my avatar--the puppy is full grown now!

(in reply to BeTheBall)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/5/2003 5:16:43   
quote:


Not sure what you are trying to do in the response.write. Where exactly do you want to redirect to?


me neither - i had orignially this:

<%
if FP_FieldVal(fp_rs,"CardsAcceptedDiners") = "yes" then 
response.write "<img src='images/logo.gif' border='0' alt='Diners card accepted'/>" 
else 
'do something for NO 
end if
%>


worked great - but now trying to change the image to a text hyperlink - nothing fancy but still beyond me :)

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: "if then" help - 12/5/2003 8:57:44   
quote:

but now trying to change the image to a text hyperlink


And you just want to link to www.leisure-ideas.com? See if this works.

<%
if FP_FieldVal(fp_rs,"CardsAcceptedDiners") = "yes" then
response.write "<a href=""http://www.leisure-ideas.com""><font size=""1"" face=""Verdana"">Visit Web Site</font>"
else
'do something for NO
end if
%>

_____________________________

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 Eli)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/5/2003 9:50:12   
yeah that works but it still doesn't work with an FP LINk like:

<% 
if FP_FieldVal(fp_rs,"Web Site") <> "" then 
response.write "<a href="FP_FieldLink(fp_rs,"Web Site")& "?www.leisure-ideas.com""><font size=""1"" face=""Verdana"">Visit Web Site</font>" 
else 
'do something for NO 
end if 
%> 


the actaul link is in the field name "Web Site". the "?www.leisure-ideas.com" is to load the link with a referrer ID.

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: "if then" help - 12/5/2003 10:00:38   
What would a sample link look like in regular html?

_____________________________

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 Eli)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/5/2003 10:02:33   
http://www.datafromfield.com?www.leisure-ideas.com

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: "if then" help - 12/5/2003 11:19:19   
I think you are close. Can you get it to work without the referrer information first? In other words, does this work?

response.write "<a href=""FP_FieldLink(fp_rs,"Web Site")""><font size=""1"" face=""Verdana"">Visit Web Site</font>"

You may have to play with the double quotes a bit. I admit I am not as proficient as others that frequent this particular forum. The reason I ask if you can get it to work without the referrer is I am wondering if you will run into the problem mention in this thread:

http://www.frontpagewebmaster.com/m-167380/tm.htm

_____________________________

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 Eli)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/5/2003 11:22:36   
quote:

ORIGINAL: betheball

I think you are close. Can you get it to work without the referrer information first? In other words, does this work?

response.write "<a href=""FP_FieldLink(fp_rs,"Web Site")""><font size=""1"" face=""Verdana"">Visit Web Site</font>"

You may have to play with the double quotes a bit.


i can get it to work like this:

response.write "<a href=""?www.leisure-ideas.com""><font size=""1"" face=""Verdana"">Visit Web Site</font>"

but nothing with FP FieldVal

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to BeTheBall)
rdouglass

 

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

 
RE: "if then" help - 12/5/2003 11:34:33   
quote:

response.write "<a href=""FP_FieldLink(fp_rs,"Web Site")""><font size=""1"" face=""Verdana"">Visit Web Site</font>"


Try using just FP_Field and use it like this:

response.write("<a href=" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com"><font size='1' face='Verdana'>Visit Web Site</font></a>")

You were trying to response write the WORD "FP_Field(fp_rs,"Web Site")" and not the DB VALUE....

Does that make sense?

< Message edited by rdouglass -- 12/5/2003 11:36:33 AM >


_____________________________

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

ASP Checkbox Function Tutorial.

(in reply to Eli)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/5/2003 11:48:50   
I'm not having a good day. Now I get a compilation error. This is what I'm using:

<%
if FP_FieldVal(fp_rs,"Web Site") = "" then
response.write("<a href=" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com"><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to rdouglass)
BeTheBall

 

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

 
RE: "if then" help - 12/5/2003 12:09:31   
quote:

<%
if FP_FieldVal(fp_rs,"Web Site") = "" then
response.write("<a href=" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com"><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>


Delete the double quote behind www.leisure-ideas.com.

Thanks rdouglas for jumping in.

_____________________________

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 Eli)
rdouglass

 

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

 
RE: "if then" help - 12/5/2003 13:10:26   
I think we're both just a little off...:)

<%
if FP_FieldVal(fp_rs,"Web Site") = "" then
response.write("<a href='" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com'><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>

Notice my single quotes? Try that one...

_____________________________

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

ASP Checkbox Function Tutorial.

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: "if then" help - 12/5/2003 13:14:35   
quote:

Notice my single quotes? Try that one...


I am not so sure on that one. I tested this (no single quotes) on my site and it worked like a charm:

"<a href="&FP_Field(fp_rs,"Link")&"?www.msn.com>Click</a>"

_____________________________

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)
rdouglass

 

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

 
RE: "if then" help - 12/5/2003 13:46:57   
quote:

I am not so sure on that one. I tested this (no single quotes) on my site and it worked like a charm:


You must be using IE...:)

I am too, but I think it's one of those times when IE compensates for us. I think other browsers could choke on it. IIRC by definition, the URL needs to be wrapped in double quotes inside an href tag like <a href="http://www.mydomain.com">. Most browsers allow us to use an apostrophe (single quote), and some (like IE) none at all...

At least that's the way I remeber it.....

_____________________________

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

ASP Checkbox Function Tutorial.

(in reply to BeTheBall)
BeTheBall

 

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

 
RE: "if then" help - 12/5/2003 13:49:44   
Interesting, thanks for sharing that. You are right, I do use IE and since most of what I do is on an intranet, so do all my users. I wonder how many mistakes I am making that I will never know about because I never use anything but IE. :)

_____________________________

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)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/8/2003 13:17:19   
This works great - kinda!

while the link is now working perfectly the if part of the statement isn't

This:

<%
if FP_FieldVal(fp_rs,"Web Site") = "" then
response.write("<a href='" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com'><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>

doesn't return anything

this:

<%
if FP_FieldVal(fp_rs,"Web Site") <> "" then
response.write("<a href='" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com'><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>

returns everything.

I'm trying to say "if this field contains anything then"

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to BeTheBall)
rdouglass

 

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

 
RE: "if then" help - 12/8/2003 13:25:13   
quote:

if FP_FieldVal(fp_rs,"Web Site") = "" then


try:

if Trim(FP_FieldVal(fp_rs,"Web Site")) = "" then

_____________________________

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

ASP Checkbox Function Tutorial.

(in reply to Eli)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: "if then" help - 12/8/2003 14:09:35   
Remeber to use the blank function, otherwise the space will be returned


if Trim(FP_Field(fp_rs,"Web Site")) = "" then

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to rdouglass)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/8/2003 14:45:12   
i have:

<%
if Trim(FP_Field(fp_rs,"Web Site")) = "" then
response.write("<a href='" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com'><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>

but still no joy :(

could it be the db?

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to Spooky)
rdouglass

 

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

 
RE: "if then" help - 12/8/2003 15:09:38   
quote:

if Trim(FP_FieldVal(fp_rs,"Web Site")) = "" then


Yup, that's specifically why I suggested FP_FieldVal - to force the space. Then I know I'm passing a string and not a null.

I really don't think it's the DB....

Maybe I'm off but my logic still brings me back to that....:):)

_____________________________

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

ASP Checkbox Function Tutorial.

(in reply to Eli)
Eli

 

Posts: 2658
From: ... er ...
Status: offline

 
RE: "if then" help - 12/8/2003 16:47:42   
fixed it by using this:

<%
if Trim(FP_Field(fp_rs,"Web Site")) > "" then
response.write("<a href='" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com'><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>


Can't say how much i have learnt about if then statements and its ALL down to you guys - thanks very much:)

_____________________________

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

(in reply to rdouglass)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: "if then" help - 12/8/2003 20:33:19   
Yep thats right, I was using this first example :-)

<%
if FP_FieldVal(fp_rs,"Web Site") = "" then
response.write("<a href='" & FP_Field(fp_rs,"Web Site") & "?www.leisure-ideas.com'><font size='1' face='Verdana'>Visit Web Site</font></a>")
else
'do something for NO
end if
%>

Rog, did you put the space code in there and the forum wiped it?

if Trim(FP_FieldVal(fp_rs,"Web Site")) <> "&nbsp;" then

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Eli)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> "if then" help
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