Forums

ASP

This topic is locked

ASP help needed

Posted 29 Jun 2005 19:36:36
1
has voted
29 Jun 2005 19:36:36 Javier Castro posted:
Hi all,

I have a list of companies that need to be linked to their respective URL. The thing is that not all of them have a URL.

<a href="#" onClick="MM_openBrWindow('<%= (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value)%>','oel','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=400')">
<%=(rsCons_Engi_Ser.Fields.Item("txtCompanyName".Value)%></a>

This is what I have right now. I works but even if there is no URL it opens a new window. How would I be able to avoid this? I tried hacking my way writing a Conditional statement, but I do not know enough to make it work. I only get Syntax error messages.

help anyone?

Javier

Replies

Replied 30 Jun 2005 20:59:58
30 Jun 2005 20:59:58 adam partridge replied:
wrap your code like this
<If rsCons_Engi_Ser.Fields.Item("txtWebsite".Value <> "" Then%>

<a href="#" onClick="MM_openBrWindow('<%= (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value)%>','oel','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=400')">
<%=(rsCons_Engi_Ser.Fields.Item("txtCompanyName".Value)%></a>

<%End If%>

Replied 05 Jul 2005 00:52:33
05 Jul 2005 00:52:33 Javier Castro replied:
Thank for replying Adam. I have tried your suggestion but it gives me the following error:

Microsoft VBScript compilation error '800a0400'

Expected statement

/oeldev/cons_engi_service.asp, line 231

End If
^


I also tried the following, but it didn't work.

<a href="#"
<%If(Not IsNull(rsCons_Engi_Ser.Fields.Item("txtWebsite".Value)) Then%>

onClick="MM_openBrWindow('<%= (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value)%>','oel','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes, resizable=yes,width=700,height=400')"

<%End If%>
><%=(rsCons_Engi_Ser.Fields.Item("txtCompanyName".Value)%></a>


I'm not sure if I explained clearly what I'm after. Please if you have any questions, let me know.

Cheers,
Javier
Replied 05 Jul 2005 18:04:58
05 Jul 2005 18:04:58 Javier Castro replied:
I have tried other solutions to my problem. Perhaps, someone else could have an idea. Here is my current state of things with the code below:

Lists the company names, highlights the links but does not link to anything. Please help, I thought, it was going to be easier than this. I WAS WRONG!

<a
<%If (Not IsNull("txtWebsite" AND (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value <> "") then
response.write "href=''" & (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value) & "target='_blank'"
End If
Response.write ">" & (rsCons_Engi_Ser.Fields.Item("txtCompanyName".Value) & "</a>"
%>
Replied 06 Jul 2005 01:34:02
06 Jul 2005 01:34:02 Javier Castro replied:
Eureka!!!! Not exactly what I had in mind but very close.

here is the code. A bit dissapointed for not receiveing more help from this forum, but I assume that everyone is busy. Cheers to Adam for giving me some suggestions.

here is my final code.

<a
<%If Not IsNull("txtWebsite" AND (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value <> "" then
response.write " href='" & (rsCons_Engi_Ser.Fields.Item("txtWebsite".Value) & "' target=_blank'"
End If
Response.write ">" & (rsCons_Engi_Ser.Fields.Item("txtCompanyName".Value) & "</a>"
%>

Reply to this topic