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

 

If THEN ELSE with Hyperlink

 
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 ELSE with Hyperlink
Page: [1]
 
Bnugent

 

Posts: 257
From: Tampa Florida Tampa, FL USA
Status: offline

 
If THEN ELSE with Hyperlink - 8/6/2008 7:04:49   
syntax is casuing me problems...I feel like I have tried every combo from the forums with no luck..

code below is giving me correct results and no errors, but it does not give me hyper link...any ideas...cant figure out how to get proper quotes, etc...so that I can get proper link?



<%
If FP_FieldVal(fp_rs,"Sales") >4999 Then
Response.write "<a href='reports_OSR_Full_Month_zdetail.asp?OSR="&FP_Field(fp,rs, "OSR")'" FormatCurrency(FP_FieldVal(fp_rs,"Sales"),0) *.05 </a>"
ElseIf FP_FieldVal(fp_rs,"Sales") > 2999 Then
Response.write "$" & FormatCurrency(FP_FieldVal(fp_rs,"Sales"),0) *.03 & " *"
Else Response.write ""
End If%>


_____________________________

Brian---
TexasWebDevelopers

 

Posts: 202
Joined: 2/22/2002
From:
Status: offline

 
RE: If THEN ELSE with Hyperlink - 8/6/2008 9:41:05   
Your hyperlink is malformed.
Code should follow format <a href="thelink">thelink</a>
Yours has no closing carat ">" and no txt for the link.
I am guessing that you want the currency as the displayed link?
So instead of this:
"<a href='reports_OSR_Full_Month_zdetail.asp?OSR="&FP_Field(fp,rs, "OSR")'" FormatCurrency(FP_FieldVal(fp_rs,"Sales"),0) *.05 </a>"
Try something like this:
<%
If FP_FieldVal(fp_rs,"Sales") >4999 Then%>
<a href="reports_OSR_Full_Month_zdetail.asp?OSR=<%=FP_Field(fp,rs, "OSR")%>"> <%=FormatCurrency(FP_FieldVal(fp_rs,"Sales"),0) *.05%></a>
<% ElseIf FP_FieldVal(fp_rs,"Sales") > 2999 Then
Response.write "$" & FormatCurrency(FP_FieldVal(fp_rs,"Sales"),0) *.03 & " *"
Else Response.write ""
End If%>

(in reply to Bnugent)
Bnugent

 

Posts: 257
From: Tampa Florida Tampa, FL USA
Status: offline

 
RE: If THEN ELSE with Hyperlink - 8/6/2008 10:16:57   
thanks for the help...I appreciat it very much...here is what I am running into:

The following works great!

When value is greater than 4999, it links them to correct page with the correct OSR number associated with that record...

<%
If FP_FieldVal(fp_rs,"SAdenosyl_Sales") > 4999 Then%>
<a href="reports_OSR_Full_Month_zdetail.asp?OSR=<%=FP_FieldURL(fp_rs,"OSR")%>"> <%=FormatCurrency(FP_FieldVal(fp_rs,"SAdenosyl_Sales"),0) *.05%></a>
<% ElseIf FP_FieldVal(fp_rs,"SAdenosyl_Sales") > 2999 Then
Response.write "$" & FormatCurrency(FP_FieldVal(fp_rs,"SAdenosyl_Sales"),0) *.03 & " *"
Else Response.write ""
End If%>

here is what I am running into however, i need to change the second elseif statement to also have a similar link like this:

<%
If FP_FieldVal(fp_rs,"SAdenosyl_Sales") > 4999 Then%>
<a href="reports_OSR_Full_Month_zdetail.asp?OSR=<%=FP_FieldURL(fp_rs,"OSR")%>"> <%=FormatCurrency(FP_FieldVal(fp_rs,"SAdenosyl_Sales"),0) *.05%></a>
<% ElseIf FP_FieldVal(fp_rs,"SAdenosyl_Sales") > 2999 Then%>
<a href="reports_OSR_Full_Month_zdetail3.asp?OSR=<%=FP_FieldURL(fp_rs,"OSR")%>"> <%=FormatCurrency(FP_FieldVal(fp_rs,"SAdenosyl_Sales"),0) *.03%></a>
Else Response.write ""
End If%>

except, when I do this, I get loop error:

Microsoft VBScript compilation error '800a040e'

'loop' without 'do'

/_fpclass/fpdbrgn2.inc, line 5

Loop
^

Any ideas why?

_____________________________

Brian---

(in reply to TexasWebDevelopers)
TexasWebDevelopers

 

Posts: 202
Joined: 2/22/2002
From:
Status: offline

 
RE: If THEN ELSE with Hyperlink - 8/6/2008 23:43:40   
When in doubt--spread things out--
Your code is basically saying "IF the field named SAdenosyl_Sales (assuming this is an integer and not a string) is greater than 4999 THEN do some math and write a link ELSE IF the field named SAdenosyl_Sales is greater than 2999 THEN do some math and write a link ELSE don't do anything and END IF"
If that sounds right then try spreading the code out:

<%
'first lets make a var that is easier to use in the code
DIM SAdenosyl_Sales
SAdenosyl_Sales=FP_FieldVal(fp_rs,"SAdenosyl_Sales")
%>
<%
If SAdenosyl_Sales > 4999 Then
%>

<a href="reports_OSR_Full_Month_zdetail.asp?OSR=<%=FP_FieldURL(fp_rs,"OSR")%>"><%=FormatCurrency((SAdenosyl_Sales),0) *.05%></a>

<%Else
End If%>

<%
If SAdenosyl_Sales > 2999 Then
%>

<a href="reports_OSR_Full_Month_zdetail3.asp?OSR=<%=FP_FieldURL(fp_rs,"OSR")%>"> <%=FormatCurrency((SAdenosyl_Sales),0) *.03%></a>

<%Else
End If%>

If that doesn't work then please paste your page code here so we take a look at the whole thing--one type of do while not...loop example is below.

So, now for the obligatory tutorial for those whe want to learn the basics:

When calling data from a database you can ditch Front Page and follow some simple steps.
You can actually use the following simple (and heavily commented) code by changing your field names and database connection information and uploading as an ASP page.
In simple terms you open the database; create a recordset; loop through all of the data in the recordset; write the data to the page; close the recordset and database connection.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>database connection</title>
</head>
<body>
<%
'First declare the vars like:
DIM DBConn, ConnectStr, Sql, Rs
'Then create a DBConnection object. This object serves to run our queries:
Set DBConn = Server.CreateObject("ADODB.Connection")
'Then make the Connection string to the DB like this:
ConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/fpdb/yourDatabase.mdb")  
DBConn.Open ConnectStr
'Then Retrieve the results in a recordset object like ths:
sql = "SELECT * FROM [table_name] ORDER by ASC"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open sql, DBConn, 3, 3
'Now we have a record set which is read/write 
Do While Not Rs.EOF
%>

HERE YOU PLACE YOUR STANDARD OUTPUT

This is a field: <%= Rs("field_name")%><br>

<%
'Now you continue to loop through the recordset  to write out all the data requested in the query string
Rs.MoveNext
Loop
'Make sure you clean up.  Not closing properly will ruin your whole day.
Rs.Close
Set DBConn = Nothing
'Also, make sure you set your connector to NOTHING after you're done with it.
'otherwise you're keeping the connector open, 
'which locks it next time you want to open that page.
%>
</body>
</html>



(in reply to Bnugent)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> If THEN ELSE with Hyperlink
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