Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Show/hide link based on db field value

Is it possible to hide/show a hyperlink based on the value of a database field?
It's a bit like a forum structure, so if there is a better way then that would be good to know.

In my case...
A record has a status either "open" or "closed"
If the status is "open", then users can enter sub-records (responses) against it by clicking on a link to respond/reply.
If the status is "closed", then I either want to
 a) make the respond link unavailable
 b) when the link is clicked, give them a message and take them to the previous page.

Help would be appreciated.

Thanks
Craig
0
CraigBFG
Asked:
CraigBFG
1 Solution
 
webwomanCommented:
Sure. You need to check the value of the field, and output the HTML based on that. And if/then/else works fine.

I don't think there's an option for this built into FrontPage, though. If you're going to start doing things that aren't part of the wizards, you're going to have to learn how to code them yourself.
0
 
hhammashCommented:
Hi,

<% If Request.Form("FieldName")="Open" Then %>
Your hyperlink
<%ELSE%>
Your other hyp
<%End If%>

I did not try it but it should work.

Regards
hhammash
0
 
hhammashCommented:
Hi,

Here is a working example:

<body>
<% If Request.Form("Country")="USA" Then %>
<p><a href="http://www.yahoo.com">www.yahoo.com</a></p>
<%ELSE%>
<p><a href="http://www.yahoo.com">www.Google.com</a></p>
<%End If%>
</body>


Regards
hhammash
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
wcameronCommented:
The solution to this is simple. Do the grunt work before you get to FrontPage. In your MS Access query us an iif statement that will display a hyperlink IF status=open and no link if status=closed.

To do this:

In your table make sure you have a field called Hyperlink and one called Status.

Now, in your query, right click in the first row of a blank query column and type the following the expression builder:

Link: iif([Status]="Open",[Hyperlink],"")

This will create a new field in the query called "Link" which will display the hyperlink only if the Status field = Open.

Make sure when you type the hyperlink into your table that you type in the entire code:

<a href="link">Caption</a>

replace "link" with the web address and "Caption" with the text you want the link to display.

In FP, when you create the DRW page, double click on the Link field value to open the field properties and select "Includes HTML". This will tell it to display the link as a hyperlink.

For more info on the iff statement, check out this tutorial.

http://64.226.199.111/frontpage/Access/queries/iifstatement/

I hope this helps
0
 
CraigBFGAuthor Commented:
With slight mod' works perfectly. Completed code :-

<%
' --------------------------------------------------
' Hides response hyperlink if status=closed
' --------------------------------------------------
If FP_FieldVal(fp_rs,"Status")="Open" Then %>
<p><a href="client_defect_response.asp">Defect</p>
<%ELSE%>
<%
End If
' --------------------------------------------------
%>

Thanks hhammash, another great tip!
0
 
hhammashCommented:
Hi,

Thank you.

You are most welcome CraigBFG.

hhammash
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now