Advertisements
Offline
shruti_sharma
Posts: 2
Joined: Sun Sep 02, 2012 7:17 pm
Hi

How to pass javascript variable in PHP?

Any help?

»ï¿½

Postby daniel88 » Tue Jan 22, 2013 11:03 am

Offline
daniel88
Posts: 11
Joined: Thu Dec 27, 2012 12:37 pm
Location: VIET NAM
You cannot pass variable values from the current page javascript to the current page PHP code... PHP code runs at the server side and it doesn't know anything about what is going on on the client side.

You need to pass variables to PHP code from html-form using another mechanism, such as submitting form on GET or POST methods.

Re: How to pass javascript variable in PHP?

Postby m3hr24d » Sun Jun 23, 2013 1:22 pm

Offline
m3hr24d
Posts: 1
Joined: Sun Jun 23, 2013 12:59 pm
Code: Select all
function myJavascriptFunction() {
  var javascriptVariable = "John";
  window.location.href = "myphpfile.php?name=" + javascriptVariable;
}