SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP and Javascript

    Does anyone know how to pass values from javascript to PHP? Thanks in advance.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ajax?
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Addict wibble wobble's Avatar
    Join Date
    Dec 2008
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo?
    Find freelance jobs from all the major sites in one place:
    on twitter / on the web / twitter rss feed

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Wrong way round wibble.

    Maraksot, do you understand the concept of server-side programming? JavaScript is client-side, therefore can only act through the browser. PHP is server-side therefore can only get variables from itself or superglobals ($_POST, $_GET, $_FILES, $_SERVER, $_SESSION).

    The only way you can send a variable from javascript to php is with a page reload, for example:
    Code javascript:
    var yourVariable = 'Hello';
    window.location = 'yourpage.php?yourVariable=' + yourVariable;

    If this isn't what you're looking for, then you probably need to rethink your reasoning for this.

    What are you trying to accomplish by doing this? There may be a much easier way.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Guru
    Join Date
    Oct 2006
    Location
    Queensland, Australia
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In what context. Explain what you're trying to achieve.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The only two ways of passing information from JavaScript to any server side language are either to load a new web page (it can be the same one) or to use Ajax to pass the information to the server without loading the page.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if I did not explain myself further. I do understand that Javascript is client-side and PHP is server-side. I was able to figure out my dilemma somehow.

    It's glad to know that there are people out there who are willing to help. Thanks to everyone who replied.


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
  •