Splitting multiple values from two different records from a database

Wayne Barron
Wayne Barron used Ask the Experts™
on
Hello, all.
(ASP Classic)

Splitting strings, in my case, I have multiple values coming from the database.

a = 94/95
b = value1/value2

Open in new window


Now, on the page, it will be.

<a href="?Type=Label&LabelID=<%=x%>" title="<%=y%>"><%=y%></a>

Open in new window


I can use a split, to get the values broken up.
However, since we are dealing with 2 different values coming in, I cannot use the split and it duplicates everything.

<%
a = split(LabelID,"/")
b = split(LName,"/")
for each x in a
for each y in b
'response.Write (x & "<br />")
%>
<a href="?Type=Label&LabelID=<%=x%>" title="<%=y%>"><%=y%></a>
<%
next
next
%>

Open in new window


So, my question is this.
How can I split it properly, to where it is only a single code that split both values?

Wayne
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Team Lead
Commented:
try use the for loop instead? and asumming both variables can split evenly...

something like:

LabelID = "94/95"
LName = "value1/value2"

a = split(LabelID,"/")
b = split(LName,"/")

for i = 0 to ubound(a)
    tmp = "<a href=""?Type=Label&LabelID="& a(i) &""" title="""& b(i) &""">"& b(i) &"</a>"
    response.write tmp
next

Open in new window

Wayne BarronAuthor, Web Developer
Top Expert 2009

Author

Commented:
thank you so much.
that did it.
except I use it like so.
the I
gave an illegal operation. which tendsa to happen from time to time.
<%
a = split(LabelID,"/")
b = split(LName,"/")
for j = 0 to ubound(a)
%>
<a href="?Type=Label&LabelID=<%=a(j)%>" title="<%=b(j)%>"><%=b(j)%></a>
<%
next
%>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial