SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Norwich
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Converting javascript variables into PHP ones

    Is there a way of doing this?

    I have a javascript variable called "browserCheck", with a value of "1".
    I want to turn this into a PHP variable called $browserCheck, with the same value.

    How can I do this?

    Thanks in advance for any help.

  2. #2
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Germany
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't turn the variable into php
    without sending it back to the server.

    Remember that the local computer is miles away from the server.
    You may use a hidden-button for example.

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Norwich
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, you're right. Looks like I have to think of another way around this problem...

    Thanks anyway.

  4. #4
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use Javascript to set a cookie, which will be sent to the server on the next page load, and you'll be able to access it via $_COOKIE['variableName'].

    Code:
    cookieDate = new Date();
    cookieDate.setDate(cookieDate.getDate() + 365);
    document.cookie = 'variableName=' + variableName + '; expires=' + cookieDate.toGMTString() + ';';
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  5. #5
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Norwich
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jeff, the cookie method works great.


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
  •