我具有php变量,我在JavaScript函数中使用它。我在Chrome上获得了结果,但是该变量在FF和IE上未定义。Alert((给出: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>
呼叫该方法: $("#avancement"(。给出在Chrome上HTML Div的进展的结果,但在FF和IE上没有任何结果。
有人可以帮我吗?
谢谢
您可以尝试从这样的php语句中删除不需要的半彩色:
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;?>"));