Hi, I hope someone can help me!

What I am trying to do is to embed some PHP code within a JavaScript function. Here is the code I have so far:

disableFunc : function (date) {
var dateTime = date.getTime();
var now = new Date().getTime();
//only allow dates more than 7 days from now
return (dateTime < (now + (6 * Date.DAY)));
},

Now, what I would like to do is to replace the '6' with a PHP variable ($Hol_Notice). Have tried the following code but it doesn't work:

disableFunc : function (date) { 
  var dateTime = date.getTime(); 
  var now = new Date().getTime(); 
  //only allow dates more than 7 days from now 
  return (dateTime < (now + (<?php $Hol_Notice?> * Date.DAY))); 
}, 

Anyone have any ideas on this?

Regards,

Andy Thomas

    I think you might have to pass the function the php variable then u can use it like so:

    $Hol_Notice = 6;
    disableFunc : function (date, Hol_Notice) {
    var dateTime = date.getTime();
    var now = new Date().getTime();
    //only allow dates more than 7 days from now
    return (dateTime < (now + Hol_Notice * Date.DAY)));
    },

      Hi,

      Thanks for your swift reply

      This didn't work! And $Hol_Notice is a variable - it isn't always 6.

      Any more ideas?

      Regards,

      Andy Thomas

        Change

        <?php $Hol_Notice?>

        to

        <?php echo $Hol_Notice?>

        Oh, and please don't double post.

           return (dateTime < (now + (<?php echo $Hol_Notice ?> * Date.DAY)));
            Write a Reply...