Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

6 of 14 people (43%) answered Yes
Recently 4 of 10 people (40%) answered Yes


How to return javascript variable values to php local variables

Apr 8th, 2008 19:06
ha mo, Dave Clark, satish indi,

     The only way to send JavaScript variable values to PHP is to 
submit these values via some form of an HTTP request.  Just off the 
top of my head I can think of at least five ways to do this:
XMLHttpRequest object (
FORM standard submission
LINK standard navigation
IFRAME hidden navigation
IMAGE tag or object
     Note that the last one can be done within JavaScript code only -- 
but it is one-way communication (though you can get a success or 
failure indication by using the onload and onerror events, too).  For 
var send = new Image();
send.onload = send_success; // your function
send.onerror = send_failed; // your function
send.src = "mypage.php?var1="+var1+"&var2="+var2+"&etc.";
Take care,
Dave Clark