#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    indonesia
    Posts
    2
    Rep Power
    0

    javascript & php


    can we pass contents of javascript's variable to php's variable ?
    Last edited by zenalimut; September 29th, 2001 at 02:31 AM.
  2. #2
  3. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    17
    yeah, certainly.

    you would just have to call up the php script properly. something like this


    var your_java_script_var;
    var url;

    url = 'http://yourserver.com/yourphpscript.php?var=" + your_java_script_var;

    now open the browser window with this url.
    also it would be good idea to url encode the url variable.

    jd
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    indonesia
    Posts
    2
    Rep Power
    0
    i haven't understood. can u explain more detail.

    can we pass the contents without refresh/use query string ?
  6. #4
  7. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    17
    see to pass variable value to php script, you can call with
    appropriate query string ( i hope you understand what is a query string ). ok ??


    now, constructin the query string in javascript is farily easy, and you just call up the script using window.open .

    and no without refersh you can't call up php script.

    jd
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  8. #5
  9. No Profile Picture
    aHVoPw==
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2001
    Posts
    1,058
    Rep Power
    15
    it appears this guy doesn't understand..

    in jdk's example:

    var your_java_script_var;
    var url;

    url = "http://yourserver.com/yourphpscript.php?var=" + your_java_script_var;


    and then you give the variable 'your_java_script_var' some kind of value in some way, whether it be from an argument of a function or set it directly or random values from an array, whatever.
    so if
    your_java_script_var = chicken;

    then
    url = "http://yourserver.com/yourphpscript.php?var=chicken";


    btw, a query string is the stuff that's after the '?' in the url...
    Visit my new IIS Tutorial Series!

IMN logo majestic logo threadwatch logo seochat tools logo