PHP code inside JavaScript
Posted: Tue Jan 22, 2008 4:57 am
Hi
How can I include some PHP code inside a JavaScript?
This is what I want to do:
the above JavaScript is held in a '.php' file.
Any ideas how this can be done?
Thanks
How can I include some PHP code inside a JavaScript?
This is what I want to do:
Code: Select all
<script type="text/javascript">
function dateChanged(calendar) {
if (calendar.dateClicked) {
var y = calendar.date.getFullYear();
var m = calendar.date.getMonth(); // integer, 0..11
var d = calendar.date.getDate(); // integer, 1..31
window.location = "/and/index.php?page=appointments&action=diary&d="+d+"&m="+m+"&y="+y;
}
};
Calendar.setup(
{
//THIS IS WHERE I WANT TO INCLUDE THE PHP CODE - SEE BELOW
date : $_REQUEST['d']."/".$_REQUEST['m']."/".$_REQUEST['m'],
flat : "calendar-container", // ID of the parent element
flatCallback : dateChanged // our callback function
}
);
</script>
Any ideas how this can be done?
Thanks