繁体   English   中英

为什么警报框不显示?

[英]why is the alert box not displaying?

这是我的代码。 如果存储在文本文件中的重置日期等于当前日期并且来自表(mysql)的数据不为零,则应显示警告框。然后应将值重置为零并删除其他记录。 我试过回显if语句,它是1。不确定为什么警告框没有弹出。

<?php 
function reset1(){
$sql=mysql_query("UPDATE tbl_txbookStock SET suppliedQuantity=0, boughtQuantity=0");
$sql=mysql_query("DELETE FROM tbl_order");
$sql=mysql_query("DELETE FROM tbl_order_book");
//overwrite date
$myFile = "config/config.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$resetDate = fread($fh, filesize($myFile));
fwrite($fh,date("m/d/Y",strtotime("+1 years")));
fclose($fh);

    }

function getCurrentDate(){
return date('m/d/Y');
}
function resetDateIsToday($resetDate){
    $itIs=false;
    if($resetDate==getCurrentDate())
        $itIs=true;

    return $itIs;
}
function isReset(){
    $isReset=false;
    if(countZeroQuantities()==countBooks()){            
        $isReset=true;
    }

    return $isReset;
}
function countBooks(){
$sql=mysql_query("select count(bookID) as count from tbl_textbook");
$row=mysql_fetch_array($sql);
return $row['count'];        
}
 function countZeroQuantities(){
 $sql=mysql_query("select count(bookID) as count FROM `tbl_txbookStock` where     suppliedQuantity>0 OR boughtQuantity>0");
$row=mysql_fetch_array($sql);
return $row['count'];   

}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>TEXTBOOK ORDERING SYSTEM</title>
<link rel="stylesheet" href="templatemo_style.css">
<?php if (!isset($_SESSION['loggedin'])){ {?>
<?php if(resetDateIsToday(getResetDate())&&!isReset()){?>

<script type="text/javascript">
<!--
function confirmReset(){
var answer = confirm ("Reset is scheduled today.Do you really want to reset?")
if (answer===1){
<?php reset1();?>       
window.location="index.php";
}else{
    alert('Records not reset...');
    window.location="index.php";
}}
// -->
</script>
<? }}}?>
</head>
<body>
</body>
</html>

我看不到您在哪里执行ConfirmReset,也许只是写

window.onload =function(e){
confirmReset();
}

在脚本的末尾

Confirm()返回true / false,并且“ true === 1”不为true。

像这样编写您的确认控件,

var answer = confirm ("Reset is scheduled today.Do you really want to reset?")
if (answer){ 
...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM