gpt4 book ai didi

javascript - 只有在我刷新页面后才会发生变化! (模态 Bootstrap )

转载 作者:行者123 更新时间:2023-11-29 21:55:19 25 4
gpt4 key购买 nike

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

<!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>

最佳答案

关闭按钮后重新加载页面。像这样的东西:

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

如果你想在发生变化时刷新,那么添加一个条件来检查是否发生了变化,如果发生了,则刷新页面

关于javascript - 只有在我刷新页面后才会发生变化! (模态 Bootstrap ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26763710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com