刷新页面后才更改! (模态引导)

时间:2014-11-05 17:45:14

标签: javascript php twitter-bootstrap page-refresh

我有一个包含拍卖产品的页面。按byd(bid)时会打开一个bootstrap模式。然后我改变金额。按下按钮。它会关闭模态,但在刷新页面之前不要更新数量。知道如何让它刷新。尝试了所有类似的问题。但是当我使用javascript它只是循环。也许我不知道在哪里输入它。 (我不卖河马:-))Thx提前。这是代码:

<!DOCTYPE html>
<html lang="da">
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1?>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<title>Produkt</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/jquery.countdown.css"> 
<script src="//code.jquery.com/jquery.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.plugin.js"></script> 
<script type="text/javascript" src="js/jquery.countdown.js"></script>
<script type="text/javascript" src="js/jquery.countdown-da.js"></script>
</head>

<body>
<?php include "config.php" ?>

<?php
$antal = $db->query('SELECT * FROM produkt');
$row_count = $antal->rowCount(); ?>
<p>Produkter i DB <span class="badge"><?php echo "$row_count" ;?></span></p>
<?php 
$bruger = 2;
$sql = "SELECT bruger.brugerNavn, produkt.produktID, produkt.produktNavn, produkt.produktPris,     produkt.dato, produkt.produktBeskrivelse
FROM bruger
LEFT JOIN produkt
ON bruger.brugerID=produkt.brugerID WHERE bruger.brugerID = $bruger";
$stmt = $db->query($sql); 
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$opretdato = $row['dato'];
$slutdato = date('Y, n, j, G, i, s',strtotime($opretdato));
?>
<script type="text/javascript">
    $(document).ready(function () {
        $('#defaultCountdown').countdown({
            until: new Date(<?php echo $slutdato; ?>)
        });
    });
</script>
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h2><?php echo $row['produktNavn']?></h2>
        </div>
        <div class="panel-body">
            <div class="col-md-6 col-lg-6">
                <div>
                    <h3>Beskrivelse</h3>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <p><?php echo $row['produktBeskrivelse'] ?></p>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body" style="padding-top:6px;">
                        <?php
                        $num = $row['produktPris'];
                        $produktPris = number_format($num,0,",",".");
                        ?>
                        <div class="col-sm-6 col-md-6 col-lg-6">
                            <h1>Kr.<?php echo $produktPris ?>,-</h1>
                        </div>
                        <div class="col-md-6 col-lg-6"></br>
                            <button type="button" class="btn btn-lg btn-success" data-toggle="modal" data-target="#myModal">BYD</button>
                        </div>
                    </div>
                </div>
                <div id="defaultCountdown" class="well"></div> 
            </div>
            <div class="col-sm-6 col-md-6 col-lg-6">
                <img src="https://c2.staticflickr.com/4/3081/3155407697_366c9f1677.jpg" class="img- responsive" alt="Image">

            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h1 class="modal-title" id="myModalLabel"><?php echo $row['produktNavn']?></h1>
            </div>
            <div class="modal-body">
                <div class="well">
                    <h1 class="text-center">Kr.<?php echo $produktPris ?>,-</h1>
                </div>
                <label for="indtastbud">Byd</label>
                <form action="" method="POST">
                    <input type="number" name="bud" class="form-control" id="exampleInputPassword1" min="<?php echo ($num + 1)?>" value="<?php echo ($num + 1) ?>">


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
                    <button type="submit" value="bud" class="btn btn-primary">BYD</button>
                </div>

            <?php
            $sql = "UPDATE produkt SET produktPris = :produktPris
            WHERE produktID = :produktID";
            $produktID = $row['produktID'];
            $stmt = $db->prepare($sql);                                  
            $stmt->bindParam(':produktPris', $_POST['bud'], PDO::PARAM_STR);
            $stmt->bindParam(':produktID', $produktID, PDO::PARAM_STR); 
            $stmt->execute();
            ?>
            </form>

        </div>
    </div>
</div>
</div>

1 个答案:

答案 0 :(得分:2)

关闭按钮后重新加载页面。类似的东西:

<button type="submit" value="bud" class="btn btn-primary" onclick="window.location.reload()">BYD</button>

如果您想在更改后立即刷新,请添加条件以检查是否已执行更改,如果已执行更改,则刷新页面