Forums
This topic is locked
Problem with a dynamically generated list
Posted 20 May 2006 04:21:39
1
has voted
20 May 2006 04:21:39 John Marsden posted:
Thanks JohnHi All
I'm making a simple ASP page displaying information about various organisations. Each record contains fields for: street, town, county and postcode displayed in a list. It works OK if all the fields contain data, but if there is an empty district in a record then I have an empty <li> and a hole in the list (well I have the bullet?). I think what I need is for the <li> to be contained in the ASP code so that it won't be rendered if the field is empty. Any pointers? The code in use is as follows:
<ul>
<li><%=(rsOrganisations.Fields.Item("orgStreet".Value)%></li>
<li><%=(rsOrganisations.Fields.Item("orgTown".Value)%></li>
<li><%=(rsOrganisations.Fields.Item("orgCounty".Value)%></li>
<li><%=(rsOrganisations.Fields.Item("orgPostcode".Value)%></li>
</ul>
I've tried inserting tags (in varied configurations) into the ASP code without much joy, though I thought that HTML tags could be placed in ASP code. I'm probably missing something obvious but I'd sure like to find it!
Thanks John
Replies
Replied 20 May 2006 22:55:27
20 May 2006 22:55:27 Javier Castro replied:
Try this:
<ul>
<% If (rsOrganisations.Fields.Item("orgStreet".Value)<> "" Then %><li><%=(rsOrganisations.Fields.Item("orgStreet".Value)%></li><% End If %>
<% If (rsOrganisations.Fields.Item("orgTown".Value)<> "" Then %><<li><%=(rsOrganisations.Fields.Item("orgTown".Value)%></li>><% End If %>
<% If (rsOrganisations.Fields.Item("orgCounty".Value)<> "" Then %><<li><%=(rsOrganisations.Fields.Item("orgCounty".Value)%></li>><% End If %>
<% If (rsOrganisations.Fields.Item("orgPostcode".Value)<> "" Then %><<li><%=(rsOrganisations.Fields.Item("orgPostcode".Value)%></li>><% End If %>
</ul>
<ul>
<% If (rsOrganisations.Fields.Item("orgStreet".Value)<> "" Then %><li><%=(rsOrganisations.Fields.Item("orgStreet".Value)%></li><% End If %>
<% If (rsOrganisations.Fields.Item("orgTown".Value)<> "" Then %><<li><%=(rsOrganisations.Fields.Item("orgTown".Value)%></li>><% End If %>
<% If (rsOrganisations.Fields.Item("orgCounty".Value)<> "" Then %><<li><%=(rsOrganisations.Fields.Item("orgCounty".Value)%></li>><% End If %>
<% If (rsOrganisations.Fields.Item("orgPostcode".Value)<> "" Then %><<li><%=(rsOrganisations.Fields.Item("orgPostcode".Value)%></li>><% End If %>
</ul>
Replied 21 May 2006 04:39:06
21 May 2006 04:39:06 John Marsden replied:
Thanks Javier. thats sorted it, though you left a few extra >'s that showed on the page till I removed them.
Again thanks John M
Again thanks John M
Replied 23 May 2006 05:05:59
23 May 2006 05:05:59 Javier Castro replied:
oops.
<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
glad you figured it out.
<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
glad you figured it out.