ASP JScript - Splitting a String into URL

Discussion in 'C#' started by mrbrantley, Jun 11, 2009.

  1. #1
    Trying to take a string like such

    girls shoes,http://www.myshoestore.com/girls.html;boys shoes,http://www.myshoestore.com/boys.html;mens shoes,http://www.myshoestore.com/mens.html etc...


    I want to split the words before the comma (,) and use that as the anchor text. I want to then split the words between the comma (,) and the semi (;) and use that as the URL. I then want to loop through the results.

    I could use something like..

    var str="Nice Shoes";
    Response.Write(str.link("http://www.myshoestore.com"));


    ... and just loop through it, adding 1 to the variable name. I just cant understand how to split that string twice and place the items properly.

    Any help? Big thanks!
     
    mrbrantley, Jun 11, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Solution in VBScript, because I am rusty in JScript! :D

    Dim strVariable
    strVariable = "girls shoes,http://www.myshoestore.com/girls.html;boys shoes,http://www.myshoestore.com/boys.html;mens shoes,http://www.myshoestore.com/mens.html"

    Dim arrURLs
    Dim arrNameValue

    arrURLs = Split(strVariable, ";")

    For i = 0 to UBound(arrURLs)
    arrNameValue = Split(arrURLs(i), ",")
    Response.Write "Text:" + arrNameValue(0) + " URL: " + arrNameValue(1)
    Next
     
    Social.Network, Jun 11, 2009 IP
  3. dopanel.com

    dopanel.com Peon

    Messages:
    93
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3

    The right answer!
     
    dopanel.com, Jun 14, 2009 IP
  4. mrbrantley

    mrbrantley Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Couldnt get it to work in JScript... so I did a VB runat server and set a session. Its a chop, but it works great.

    Thanks for the help guys!
     
    mrbrantley, Jun 23, 2009 IP