SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript query string

    I have this javascript query string I'm using within
    a php script,

    Code:
    $string="getSub('subcat.php?cat='+this.value)";
    it works as it is, passing the value of cat,
    the challenge is, I want to attach another value, say 's=$s', to the
    string(making two now - cat and s), don't know how to rightly
    append this in javascript.

    Thanks.

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Parameters in a query string are separated by the ampersand symbol (&).

    Just add additional parameters (like you added the cat parameter) after cat and separate them with an ampersand.

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tried that before. Didn't work.

  4. #4
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Can you clarify what you're trying to do versus what's actually happening? What isn't working?
    I'm the web overlord for Graphic Business Systems

  5. #5
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tentim View Post
    Tried that before. Didn't work.
    I'm not sure how you expect anyone to tell you what you have done wrong if you don't post your code

  6. #6
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks. The code is just what i posted before, i
    wanted to add another value to the query string, since
    it's a javascript snippet, using & directly didnt work-i
    needed to concatenate the javascript way.

    Got it working though:

    Code:
    $string="getSub('subcat.php?cat='+this.value+'&s='+$s)";


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
  •