Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to get a string from a url

    This is probably easy if I knew Javascript. Can someone show me the code to get the number "800014352" part from the url????

    http://testebiz/ebizbtest/ShoppingCa...2/Default.aspx

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by whippet19027 View Post
    This is probably easy if I knew Javascript. Can someone show me the code to get the number "800014352" part from the url????

    http://testebiz/ebizbtest/ShoppingCa...2/Default.aspx
    Which url are we talking about?

    Is this what you mean?

    Code:
    var url ="http://www.codingforums.com/showthread.php?t=181928";
    var num = url.replace(/[^0-9]/g,"")
    alert (num);

    Two legs on a stool are no better than one.
    Last edited by Philip M; 03-10-2011 at 06:49 PM.

  • #3
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is the url now showing up???

  • #5
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i mean is the url not showing up???

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by whippet19027 View Post
    i mean is the url not showing up???
    No. Appears to have a typo in it.

  • #7
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is what i mean

    http://website/blah/181928/index.htm

    i need to get at the number in the url

  • #8
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by Philip M View Post
    Which url are we talking about?
    The link in the OP's URL is:

    Maybe something like this:

    Code:
    var url = 'http://testebiz/ebizbtest/ShoppingCart/ACPOrderSummary/tabid/161/ORDERNUMBER/8000145352/Default.aspx';
    var num = url.replace(/[\s\S]*ORDERNUMBER\/(.*?)\/[\s\S]*/gi,'$1');
    alert('The extracted order number is ' + num);
    I'm assuming that "/ORDERNUMBER/" will always be in the URL... the regex may need to be adjusted accordingly.

    -- Roger
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #9
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by whippet19027 View Post
    this is what i mean

    http://website/blah/181928/index.htm

    i need to get at the number in the url
    Your links are dead. a LITTLE more help would.... um... help.
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #10
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These urls are behind a firewall.

    Ok this is what I am trying to do. I am trying to get an order numbers from url's. Originally the urls had a parameter ?ORDERNUMBER=123456 but the vendor changed this and now the urls have the order number in the path of the url.

    This is what I was using originally to get the order number

    <script>
    function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
    return pair[1];
    }
    }

    }
    </script>

    Krupski what you did works I just dont know how to change the function to do what you did

  • #11
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Figure it out. Thanks a lot for your help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •