SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2008
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get values from querystring

    I would like to be able to get different values I sent from one page to another in the querystring...

    I would like to be able to do something like this:

    1. having this url: http://localhost/folder/page.htm?q=test&s=querystring

    and, let's say, this function: getValuesFromQS(key)

    2. in the page.htm:
    Code JavaScript:
    alert(getValuesFromQS('q'));
    alert(getValuesFromQS('s'));


    Anyone knows how can I do this, please?

    TIA.
    Proud member of this community.
    ____________________________

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Use the querystring API from http://adamv.com/dev/javascript/querystring

    Then you can use

    Code javascript:
    var qs = new Querystring();
    alert(qs.get('q'));
    alert(qs.get('s'));
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2008
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Paul!
    Proud member of this community.
    ____________________________


Bookmarks

Posting Permissions

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