Forums

This topic is locked

Displaying URL's

Posted 18 Dec 2003 12:42:09
1
has voted
18 Dec 2003 12:42:09 kirsty burgoine posted:
I'm trying to create a detail page that only shows a link to another website if there is a website address listed in my database.
Heres my code:
<% websitetodisplay = rsAdmiraDealers("Website" %>
<% IF websitetodisplay <> "" THEN %>
<a href="<% = websitetodisplay %>"><b>Visit Us</b></a>
<% END IF %>
Unfortunately, although this hides the link when there is no address, the displayed links do not work. I get a HTTP 404 error on all the links.
Please can someone help.
Thanks
Kirsty

Replies

Replied 18 Dec 2003 13:36:01
18 Dec 2003 13:36:01 Dave Thomas replied:
try this off top of my head

<pre id=code><font face=courier size=2 id=code>
&lt;%
Dim websitetodisplay
websitetodisplay = rsAdmiraDealers.Fields.Item("Website".value %&gt;
&lt;% IF websitetodisplay &lt;&gt; "" THEN %&gt;
&lt;a href="&lt;%= websitetodisplay %&gt;" target="_new"&gt;&lt;b&gt;Visit Us&lt;/b&gt;&lt;/a&gt;
&lt;% END IF %&gt;
</font id=code></pre id=code>


Regards,
Dave

UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
Replied 18 Dec 2003 14:11:28
18 Dec 2003 14:11:28 kirsty burgoine replied:
Thanks,
I tried your code but it didn't work so I modified it a bit to this:
&lt;% websitetodisplay = rsAdmiraDealers.Fields.Item("Website".value %&gt;
&lt;% IF websitetodisplay &lt;&gt; "" THEN %&gt;
&lt;a href="&lt;%= websitetodisplay %&gt;" target="_new"&gt;&lt;b&gt;Visit Us&lt;/b&gt;&lt;/a&gt;
&lt;% END IF %&gt;
But this brings back my original error.
I have checked the addresses in my database are correct so I'm at a bit of a loss.
Replied 18 Dec 2003 15:12:42
18 Dec 2003 15:12:42 Wayne Hultum replied:
Silly question, but have you set the field "Data Type" that the web address is in to "Hyperlink"?

Hope that makes sense to you.
Replied 18 Dec 2003 15:21:53
18 Dec 2003 15:21:53 kirsty burgoine replied:
Hi,
I hadn't set that which was abit silly but I have now but its still not working.
Replied 18 Dec 2003 15:26:27
18 Dec 2003 15:26:27 Wayne Hultum replied:
are your links stored in the database with the full url? www.domain.com or just www.domain.com
Replied 18 Dec 2003 15:33:55
18 Dec 2003 15:33:55 kirsty burgoine replied:
I had listed them as www.domain.com but I tried www.domain.com and interestingly it loaded the page with the link in a new window!!
Replied 18 Dec 2003 15:40:04
18 Dec 2003 15:40:04 Wayne Hultum replied:
if you want the page to open in the same window remove <b>target="_new"</b>

Have you got it how you want it now?
Replied 18 Dec 2003 17:06:45
18 Dec 2003 17:06:45 kirsty burgoine replied:
Sorry I meant that the original page loads in the new window not the page I want.
I've tried taking the new window out but now it just reloads the original page in the same window.
Replied 18 Dec 2003 17:26:41
18 Dec 2003 17:26:41 Dave Clarke replied:
Hi
Try this

&lt;% If Not rsAdmiradealers.EOF Or Not rsAdmiradealers.BOF Then %&gt;
&lt;a href="&lt;%=(rsAdmiradealers.Fields.Item("Website".Value)%&gt;"&gt;visit
us&lt;/a&gt;
&lt;% End If %&gt;

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Edited by - Davecl on 18 Dec 2003 17:28:08
Replied 18 Dec 2003 18:03:24
18 Dec 2003 18:03:24 Dave Thomas replied:
nice tutorial for it

www.webthang.co.uk/tuts/tuts_dmx/showhide/showhide1.asp

Regards,
Dave

UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
Replied 19 Dec 2003 11:07:16
19 Dec 2003 11:07:16 kirsty burgoine replied:
Ok,
I've got the display thing right so the web address only shows if there is one in the database.
Heres my code:

&lt;div align="center"&gt;Web: &lt;%=(rsAdmiraDealers.Fields.Item("Website".Value)%&gt;&lt;/div&gt;

but what I wanted was to not display the actual web address but have a link there instead
i.e 'Visit Us' and that takes you to the address in the database.

Can someone help?
Replied 19 Dec 2003 12:57:39
19 Dec 2003 12:57:39 Wayne Hultum replied:
Try this
<pre id=code><font face=courier size=2 id=code>&lt;a href="&lt;%=(rsAdmiradealers.Fields.Item("Website".Value)%&gt;"&gt;visit
us&lt;/a&gt;
</font id=code></pre id=code>
Replied 19 Dec 2003 17:46:50
19 Dec 2003 17:46:50 Dave Thomas replied:
use this for a link stored as www.etc....

&lt;a href="&lt;%=(rsAdmiraDealers.Fields.Item("Website".Value)%&gt;"&gt;Visit Us&lt;/a&gt;

and use Waynes above ^^ for a link stored as www.etc....

Regards,
Dave

UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
Replied 19 Dec 2003 17:53:28
19 Dec 2003 17:53:28 kirsty burgoine replied:
I managed to get it working now thanks.
What I did was this:

&lt;% websitetodisplay = rsAdmiraDealers.Fields.Item("Website".value %&gt;
&lt;% If websitetodisplay &lt;&gt; "" Then %&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt;&lt;a href="&lt;% = websitetodisplay %&gt;" target="_new"&gt;&lt;b&gt;Visit Us&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;% End If %&gt;

I also made sure the addresses in my database started and I also made sure that the data type of that field in access was set to 'text' not hyperlink.
I don't know whether its right or not but its worked so thanks for your help guys.

Reply to this topic