我正在尝试使用语义的Modal,我在我的模态中放了一个PHP,但它不起作用,为什么? 我知道我的模态是由JavaScript生成的,通常这个脚本是为了返回我的变量消息中的消息。
脚本:
<?php $message = ""; ?>
<body>
<button class="ui primary button" type="button" id="openModal">
apparaitre modal
</button>
<form class="ui form modal" method="post">
<div class="header">
Modal Title
</div>
<div class="image content">
<div class="image">
An image can appear on left or an icon
</div>
<div class="description">
A description can appear on the right
<?php
echo $message;
?>
</div>
</div>
<div class="actions">
<div class="ui button">Cancel</div>
<div class="ui button" type="submit" name="val">OK</div>
</div>
</form>
<?php
if(isset($_POST['val'])) {
$message = "3 essais restant";
}
?>
<script>
$("#openModal").click(function () {
$('.ui.modal').modal('show');
});
</script>
</body>
</html>
答案 0 :(得分:-1)
我想你想在你的模特中留言?
如果是这样,您需要更改代码。导致消息仍为空。首先你把它设置为空,然后填写它。 首先填充变量然后显示它。像这样:
<?php
$message = "";
if(isset($_POST['val'])) {
$message = "3 essais restant";
}
?>
<body>
<button class="ui primary button" type="button" id="openModal">
apparaitre modal
</button>
<form class="ui form modal" method="post">
<div class="header">
Modal Title
</div>
<div class="image content">
<div class="image">
An image can appear on left or an icon
</div>
<div class="description">
A description can appear on the right
<?php
echo $message;
?>
</div>
</div>
<div class="actions">
<div class="ui button">Cancel</div>
<button class="ui button" type="submit" name="val">OK</button>
</div>
</form>
<script>
$("#openModal").click(function () {
$('.ui.modal').modal('show');
});
</script>
</body>
</html>