Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Classic ASP VBScript:  How to separate comma-delimited listings into individual, dynamic links.

Posted on 2007-10-19
16
Medium Priority
?
722 Views
Last Modified: 2008-01-09
Classic ASP VBScript
MS Access
DWMX
WIN XP PRO

Hello.  I have created a recordset and one of the fields has a list of comma-delimited values.  How can I separate each of these value into individual links without creating another table for individual records?

The table is:  [Team Members]
The field is: {tm_mentee}

The tm_mentee values would look like:  (202800, 202810, 202820), etc.

Each of these numbers represents a Team Member.

I would like to make them individual links, if that's possible.  Obviously when I just link the initial dynamic content, it lists all of the numbers, but makes all of them one, big link.


Thanks so much,
Shane
0
Comment
Question by:lshane
  • 6
  • 5
  • 5
16 Comments
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20112636
the easiest way is to use the 'split' function to create an array, then loop through the array and create a link within the loop body...

http://www.w3schools.com/vbscript/func_split.asp
0
 

Author Comment

by:lshane
ID: 20112723
Hello, basicinstinct.  Thank you for replying.  I viewed that section from your link, but I'm a little unsure how to implement that with my field.  Here's my recordset:

=============================================================================
<%
Dim rsMenteeList
Dim rsMenteeList_numRows

Set rsMenteeList = Server.CreateObject("ADODB.Recordset")
rsMenteeList.ActiveConnection = MM_connPMDData2_DSN_STRING
rsMenteeList.Source = "SELECT *  FROM team_members  WHERE tm_ID = " + Replace(rsMenteeList__MMColParam, "'", "''") + ""
rsMenteeList.CursorType = 0
rsMenteeList.CursorLocation = 2
rsMenteeList.LockType = 1
rsMenteeList.Open()

rsMenteeList_numRows = 0
%>
=============================================================================

There is a MEMO field in that table called "tm_mentee", and it contains a comma-delimited list, such as the one I posted above.  

On the page where the dynamic content is viewed, I type:  "<a href="#"><%=(rsMenteeList.Fields.Item("tm_mentee").Value)%></a>".

There's not a loop anywhere.  I just want to split out the list in that MEMO field and make them individual links.

Any ideas?

Thanks so much,
Shane
0
 
LVL 25

Expert Comment

by:kevp75
ID: 20112768
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value)
for i = 0 to ubound(strLinks)
    response.write("<a href=""#"">" & strLinks(i) & "</a>")
next
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:lshane
ID: 20112827
Hello, kevp75.  Where would I place this section of code?


Thanks so much,
Shane
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20112847
replace your existing code:

"<a href="#"><%=(rsMenteeList.Fields.Item("tm_mentee").Value)%></a>".

with kevs function
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20112859
but it should be this:

dim strLinks
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value, ",")
for i = 0 to ubound(strLinks)
    response.write("<a href=""#"">" & strLinks(i) & "</a>")
next
0
 
LVL 25

Expert Comment

by:kevp75
ID: 20112869
aye....forgot the character to split on....
0
 
LVL 23

Assisted Solution

by:basicinstinct
basicinstinct earned 800 total points
ID: 20112875
yep...

and probably want to trim it too:

dim strLinks
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value, ",")
for i = 0 to ubound(strLinks)
    response.write("<a href=""#"">" & trim(strLinks(i)) & "</a>")
next
0
 

Author Comment

by:lshane
ID: 20112949
Ok, thank you, but still getting probs.

I replaced my code with the function in this way:
==============================================================
<%dim strLinks
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value, ",")
for i = 0 to ubound(strLinks)
    response.write("<a href=""#"">" & trim(strLinks(i)) & "</a>")
next%>
==============================================================

... but my result was:

202802202804202811  

Pretty much what I had.

Am I doing something wrong?

Thanks,
Shane
0
 

Author Comment

by:lshane
ID: 20113131
Did my last posting come through?
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20113308
well just to confirm, when you do this:

<%=(rsMenteeList.Fields.Item("tm_mentee").Value)%>

you get a comma separated list of values right?  can you post the output of that here?
0
 
LVL 25

Expert Comment

by:kevp75
ID: 20113313
do this:

<%dim strLinks
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value, ",")
for i = 0 to ubound(strLinks)
    response.write("<a href=""#"">" & trim(strLinks(i)) & "</a><br />")
next%>
0
 

Author Comment

by:lshane
ID: 20113350
Hey, kevp75.  That did it!  Here's the result:

202802
202804
202811

I do have one other piggy-back question for this, but if I need to re-thread, I will.

What I REALLY need to do is send the value of each of those value in a string:
<some_process_page.asp?MenteeNumber=...>

They are links, but hw can I get each of those to send their own value?


Thanks SO much,
Shane
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 1200 total points
ID: 20113355
change your URL!

<%dim strLinks
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value, ",")
for i = 0 to ubound(strLinks)
    response.write("<a href=""some_process_page.asp?MenteeNumber=" & trim(strLinks(i)) & """>" & trim(strLinks(i)) & "</a><br />")
next%>
0
 

Author Comment

by:lshane
ID: 20113378
Thank you both for your input.  I awarded kevp75 more points for the solution.

Thank you, basicinstinct, for jumping in and catching the details.

Thanks so much,
Shane

P.S. I may be back with another question related to this, as I would really like to show the Employee names that match these values, but I will see if I can get it to work over here.
0
 
LVL 25

Expert Comment

by:kevp75
ID: 20113780
thanks for the grade :)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question