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
CraigBFGAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.