a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

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

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

 

response.write asp

 
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 >> response.write asp
Page: [1]
 
walrus

 

Posts: 554
Joined: 3/13/2003
From: London
Status: offline

 
response.write asp - 4/27/2003 5:43:50   
Here is what Im trying to do
If statement to response.write " Email" if the field
<%=FP_FieldVal(fp_rs," Email" )%>

contains an address. Blank otherwise.
Heres the tricky bit. This is then a mailto: link.
I just cant get the syntax right.
Can anyone help?

This is what I have so far
<%
if FP_FieldVal(fp_rs," Email" ) = " "  then
response.write " " 
else
response.write <a href=" mailto:FP_FieldVal(fp_rs," Email" )" >Email</a>
end if
%>

Syntax error


< Message edited by walrus -- 4/27/2003 6:29 AM >


_____________________________

I hope The Boss isn't reading this, ...she thinks I program everything!
Spooky

 

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

 
RE: response.write asp - 4/27/2003 7:42:20   

<%
if FP_Field(fp_rs," Email" ) = " "  then
response.write " " 
else
response.write " <a href=" " mailto:" &FP_Field(fp_rs," Email" )&" " " >Email</a>" 
end if
%>



_____________________________

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

§þ:)


(in reply to walrus)
walrus

 

Posts: 554
Joined: 3/13/2003
From: London
Status: offline

 
RE: response.write asp - 4/27/2003 8:41:44   
Thanks Spooky, again:)
Im really getting into this asp coding now. I see how the syntax works on this, but it seems like an extra pair of quotes
 response.write " <a href=[color=#993300]" [/color]" mailto:" &FP_Field(fp_rs," Email" )&" " [color=#993300]" [/color]>Email</a>" 

:)Im curious to know what these represent....

_____________________________

I hope The Boss isn't reading this, ...she thinks I program everything!

(in reply to Spooky)
walrus

 

Posts: 554
Joined: 3/13/2003
From: London
Status: offline

 
RE: response.write asp - 4/27/2003 8:56:00   
The mailto: link works well. Only problem is that " Email" is displayed even where the field is empty.
Makes me wonder whether
if FP_Field(fp_rs," Email" ) = " "  then
response.write " "  

is correct. Seems to be.
Any better suggestions anyone?
Thanks

_____________________________

I hope The Boss isn't reading this, ...she thinks I program everything!

(in reply to Spooky)
Spooky

 

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

 
RE: response.write asp - 4/27/2003 10:46:58   
It depends whats in the database, perhaps there are spaces?

if Trim(FP_Field(fp_rs," Email" )) = " "  then
response.write " "  


To do quotes in asp, you have to be careful to include the right amount.

Consider this :

response.write " Bob said " Hello" 

You have 3 quotes. 1 Represents the opening of a string. The 2nd, part of the string is a quote, but still part of the string.
However, vb interprets it as the close of a sting (matched pair) and would generate an error. " Expected end of statement "

Now consider this :
response.write " Bob said " " Hello" "  

With 2 quotes, vb now interprets this as a single quote.
However, as there are a total of 5 quotes, an error " Unterminated string constant " will be generated as the string is not closed.

This would be a valid string :
response.write " Bob said " " Hello" " "   


Add some html :
response.write " Bob said <font size=" " 10" "  face=" " verdana" " >" " Hello" " "  


Add a variable:
response.write " Bob said <font size=" " " &Fontsize&" " "  face=" " verdana" " >" " Hello" " "  








_____________________________

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

§þ:)


(in reply to walrus)
walrus

 

Posts: 554
Joined: 3/13/2003
From: London
Status: offline

 
RE: response.write asp - 4/27/2003 11:07:44   
Ahhaaa!!!
Trim

Thanks for explaining the quotes
So
response.write " Bob said " Hello" " 
doesn' t work then

_____________________________

I hope The Boss isn't reading this, ...she thinks I program everything!

(in reply to Spooky)
walrus

 

Posts: 554
Joined: 3/13/2003
From: London
Status: offline

 
RE: response.write asp - 4/27/2003 11:16:14   
Unfortunately Trim doesnt fix the problem although a hell of a useful command nonetheless.
The field will either contain an email address, ie no spaces, or is left empty.
I have checked that it is not required and can be zero length (you taught me well:)).
Any other suggestions?

_____________________________

I hope The Boss isn't reading this, ...she thinks I program everything!

(in reply to Spooky)
Spooky

 

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

 
RE: response.write asp - 4/27/2003 11:54:48   
You are using if FP_Field(fp_rs," Email" ) and not if FP_FieldVal(fp_rs," Email" ) ?

(in reply to walrus)
walrus

 

Posts: 554
Joined: 3/13/2003
From: London
Status: offline

 
RE: response.write asp - 4/27/2003 12:04:45   
:) Sorry
I thought we were working on the quotes.
I missed that.

:)It works

_____________________________

I hope The Boss isn't reading this, ...she thinks I program everything!

(in reply to Spooky)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> response.write asp
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