Hyperlinking FP wit an If Else (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


WIryeman -> Hyperlinking FP wit an If Else (5/5/2003 22:59:35)

Help,

I can' t get this work, becides the obvious, its wrong , I am stumped. Any Ideas?

<%If FP_FieldVal(fp_rs," M1" )>= 0 Then
response.write " <a href=macklake.asp?M1=FP_FieldURL(fp_rs," M1" ) FP_FieldVal(fp_rs," M1" )</a>"
Else
response.write" "
End If
%>

This is the error repsonse
Microsoft VBScript compilation error ' 800a0401'

Expected end of statement

/Lakes/lakedetail.asp, line 299

response.write " <a href=macklake.asp?M1=FP_FieldURL(fp_rs," M1" ) FP_FieldVal(fp_rs," M1" )</a>"
-----------------------------------------------------------^

Thanks
Ryeman




Spooky -> RE: Hyperlinking FP wit an If Else (5/5/2003 23:08:12)

<%If FP_FieldVal(fp_rs," M1" )>= 0 Then 
response.write " <a href=" " macklake.asp?M1=" &FP_FieldURL(fp_rs," M1" )&" " " >" & FP_FieldVal(fp_rs," M1" )&" </a>"  
Else 
response.write " "  
End If 
%>


Assuming all M1 values are numeric, and you wish to perform a comparison, youll have to use cInt(FP_FieldVal(fp_rs," M1" ))




WIryeman -> RE: Hyperlinking FP wit an If Else (5/5/2003 23:19:27)

That did it Thanks Spooky




Spooky -> RE: Hyperlinking FP wit an If Else (5/5/2003 23:42:35)

A slightly more efficient way is to do it like so :

<%
DIM M1
M1=FP_FieldVal(fp_rs," M1" )

If M1>= 0 Then
   response.write " <a href=" " macklake.asp?M1=" &M1&" " " >" &M1&" </a>"    
Else   
response.write " "    
End If   
%>




WIryeman -> RE: Hyperlinking FP wit an If Else (5/6/2003 21:29:07)

Spooky,

After slight modification I got the first one to work, the second one kept bommbing off. Something it didn' t like in the " Else"

When I try to run the code 2 or 3 times like below I keeping getting error in the second exectution:

" Microsoft VBScript runtime error ' 800a000d'

Type mismatch: ' [string: "  " ]'

/Lakes/lakedetail.asp, line 301

Here is my code...

<td width=" 27" height=" 27" >
<%If FP_FieldVal(fp_rs," M1" )>= 1 Then
response.write " <a href=" " macklake.asp?M1=" &FP_FieldURL(fp_rs," M1" )&" " " >" & FP_FieldVal(fp_rs," M1" )&" </a>"
Else response.write " "
End If %></td>
<td width=" 27" height=" 27" >
<%If FP_FieldVal(fp_rs," M2" )>= 1 Then
response.write " <a href=" " macklake.asp?M2=" &FP_FieldURL(fp_rs," M2" )&" " " >" & FP_FieldVal(fp_rs," M2" )&" </a>"
Else response.write " "
End If %></td>
<td width=" 27" height=" 27" >
<%If FP_FieldVal(fp_rs," M3" )>= 1 Then
response.write " <a href=" " macklake.asp?M3=" &FP_FieldURL(fp_rs," M3" )&" " " >" & FP_FieldVal(fp_rs," M3" )&" </a>"
Else response.write " "
End If %></td>

Thanks
Ryeman




Spooky -> RE: Hyperlinking FP wit an If Else (5/6/2003 21:54:46)

Thats the numeric comparison I was talking about.

You cant do >= when the result is a string.
You can only do
If this<>" that" OR This=" that"

For numeric values, you can use the normal operators
If thisNumber <> 0 or thisNumber >=0





WIryeman -> RE: Hyperlinking FP wit an If Else (5/7/2003 12:23:38)

Spooky,
[:j] Sorry I read your numeric statement as refering to the code above it...

So something like this should work?

<% DIM M1
M1=CInt(FP_FieldVal(fp_rs," M1" ))
If M1>= 1Then
response.write " <a href=" " macklake.asp?M1=" &M1&" " " >" &M1&" </a>"
Else
response.write " "
End If
%>

I read some where that I can drop the " Else and " End If" because I am only testing if is true and doing something only if it is true.

So this should work too?

<% DIM M1
M1=CInt(FP_FieldVal(fp_rs," M1" ))
If M1>= 1 Then
response.write " <a href=" " macklake.asp?M1=" &M1&" " " >" &M1&" </a>"
%>

I am away from my home computer. Rethorical? Unless you see a flaw.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.152344E-02