Hi,

Can anybody tell me why in the following peace of code the link does
not get hidden when "locationid" is empty? thanks, torsten

<%if IsNull(cursor("locationid")) = false then %><A
href="javascript:MM_openBrWindow('<%
=cursor("locationid")
%>&source=82YWNH0INZZDY-zIkhkce2L£wY!Pbgx6&zoom=<%
=cursor("mapbytezoom")
%>','','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,width=585,height=585,screenX=0,screenY=0,top=0,left=0');"
onMouseOver="window.status = 'Link To Location Map'; return true;"
onMouseOut="window.status = ''; return true;"><IMG
SRC="../images/pubs/gpg_getmap_button.gif" WIDTH=58 HEIGHT=38 HSPACE=0
VSPACE=0 BORDER=0 ALT="Get Map"></A><% end if%>

Dani AI

Generated

Two likely causes explain why the link still appears: the DB field often contains an empty string (""), not Null, so IsNull(...) returns False; and the anchor/JS in the original post is tangled by quoting/markup which can mask the condition or break the output (as hinted with "syntax error"). 's JSTL suggestion is sensible for JSP, but it doesn't apply to classic ASP — a server‑side presence check is the right approach here.

A safe, minimal server‑side pattern for classic ASP:

<%
Dim locId
locId = cursor("locationid")   ' or rs("locationid")
If Not IsNull(locId) And Trim(CStr(locId)) <> "" Then
%>
<a href="#" onclick="window.open('http://example.com/viewlocation?locationid=<%= Server.URLEncode(locId) %>','mapwin','width=585,height=585'); return false;">
  <img src="../images/pubs/gpg_getmap_button.gif" width="58" height="38" alt="Get Map" />
</a>
<%
End If
%>

Reasons and quick tips:

  • Check IsNull first to avoid runtime errors, then Trim(CStr(...)) to detect empty strings.
  • Server.URLEncode prevents malformed query strings.
  • Prefer onclick="window.open(...); return false;" to avoid nested-quote pain inside an href.
  • For debugging, write the raw value into an HTML comment: Response.Write "<!-- locId:[" & Server.HTMLEncode(CStr(locId)) & "] -->" to inspect what the field actually contains in the page source.
  • If using an ADO recordset, also confirm there is a current record (If Not cursor.EOF Then) before reading the field.

This pattern removes ambiguity about Null vs empty string and avoids quoting problems that commonly cause the link to remain visible.

Recommended Answers

All 2 Replies

there s synax error .....verify

<c:if test="${not empty urldata}"><a href="<c:out value='${urldata}'/>"><c:out value="${urldescription}"/></a></c:if>

Now isn't that a simple and clean bit of code?
Learn to use JSTL and ditch those scriptlets. They're 7 year old technology and no longer recommend.
In fact on any new project I ban the use of scriptlets, dictate JSTL is used exclusively.
Any JSP containing scriptlets gets thrown back to the programmer for rework.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.