如何从JavaScript文件中获取值并将其发送到PHP文件?

Can you tell me how to take a value from a JavaScript file and send it to a PHP file?

Code:

var year      = (year != null) ? year : '".$this->arrToday["year"]."';


var month     = (month != null) ? month : '".$this->ConvertToDecimal($this>arrToday["mon"])."';


var day       = (day != null) ? day : '".$this->arrToday["mday"]."';


my_window= window.open ('Event.php','mywindow1','status=1,width=350,height=150'); 

\\

I want to send the variables (year,Month,day) to Event.php.

Can you tell me how?

You can use ajax to send JS variables to php (look at jQuery), but you can't execute php code through javascript. Another way (if you must use those variable in a new page) is to pass js variables as GET variables something like:

my_window= window.open ('Event.php?year=2010','mywindow1','status=1,width=350,height=150');

and in php:

echo $_GET["year"]; //prints 2010
var url = "event.php?year="+year+"&month="+month+"&day"+day;

var win1 = window.open(url,"File name","height=150,width=350,fullscreen=0,location=1,menubar=0,resizable=0,scrollbars=1,status=1,toolbar=0,left=0,top=30");

win1.focus();

In event.php file

Use $_GET['day'], $_GET['month'], $_GET['year'] to get the values