SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Variables Passed In The URL

    Ok, I have used PHP to send a variable in the url and I then need to use Javascript to send it on again. How would I pick up the variable? It is passeed as var=x. I am fairly sure I know how to pass it on I jsut need to get this value into a variable.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    location.search returns everything after the ? in the url, you can then split it and dig out the variables you need

  3. #3
    SitePoint Member
    Join Date
    May 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use php to get the var and x. Then make it put something like

    <script ..>
    var <?= $var ?> = <?= $x ?>;
    </script>


    somewhere in the html

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK , Venut yours looks easiest but I don't quite get you.

  5. #5
    SitePoint Enthusiast Northern Star's Avatar
    Join Date
    Aug 2006
    Location
    Cheshire, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bumfluff
    OK , Venut yours looks easiest but I don't quite get you.
    Think he's trying to say you should use PHP to get the QueryString and then generate the JavaScript using that.


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
  •