I have a php variable and i use it in a javascript function. I get the result on chrome, but the variable was undefined on FF and IE. The alert() give: NaN.
<?php
require('connection.php');
$mod=$_POST['mod'];
$req=$bdd->prepare('SELECT * FROM theo WHERE affaire=?');
$req->execute(array($mod));
$tableau=$req->fetchAll(PDO::FETCH_ASSOC);
//var_dump($tableau);
foreach ($tableau as $key => $t)
{
$date_theo_cre=$t['date_theo_cre'];
$date_theo_fin=$t['date_theo_fin'];
}
$req->closeCursor();
?>
<script>
$(function(){
// Initialisation des champs
$('#dateJour').val(convertDateToString(new Date()));
});
var minDate = new Date(Date.parse("<?php echo $date_theo_cre;?>;"));
var today = new Date();
var maxDate = new Date(Date.parse("<?php echo $date_theo_fin;?>;"));
// Mise à jour de l'avancement
var nbJoursTotal = Math.floor((maxDate.getTime() - minDate.getTime()) /
86400000);
var nbJoursPasses = Math.floor((today.getTime() - minDate.getTime()) /
86400000);
var pourcentage = nbJoursPasses / nbJoursTotal * 100;
// On gère les cas limites
if (pourcentage < 0) {
pourcentage = 0;
} else if (pourcentage > 100) {
pourcentage = 100;
}
$("#avancement").reportprogress(pourcentage);
</script>
The call to the method: $("#avancement").reportprogress(pourcentage); give the result of the progress in an HTML div on chrome but nothing on FF and IE.
Can anyone please help me out?
Thanks
Date.parse("<?php echo $date_theo_cre;?>;")extra colon is here. Remove it and check it once.