SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to return values from javascript to PHP

    hi all,
    Can someone tell me how to return values from javscript function to php variable.

    function lookin()
    {
    var eleContent=document.getElementById('content');
    var el=eleContent.childNodes[0].firstChild.nodeValue;
    retun el;
    }

    now i want this el to return in some php variable???
    cans omeone help me here.Its urgent thanks!!!
    regards,

  2. #2
    SitePoint Enthusiast navtej's Avatar
    Join Date
    May 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by priti
    hi all,
    Can someone tell me how to return values from javscript function to php variable.

    function lookin()
    {
    var eleContent=document.getElementById('content');
    var el=eleContent.childNodes[0].firstChild.nodeValue;
    retun el;
    }

    now i want this el to return in some php variable???
    cans omeone help me here.Its urgent thanks!!!
    regards,
    basically I dont know php cause I know .net , but i have and idea , if you can assign the value to a control eg: input box then use it in php variable.


    what I am asumming you are posting cause js is client side and cant directly intact with the server without post back

    the other option can be ajax.

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can only provide variables to your PHP scripts at the point the page is compiled (i.e. before it is sent to your browser). Once the page is in the browser it is on your machine, so the only way you can send variables from a Javascript script to PHP is by loading a new page (or using Ajax as navtej says).


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
  •