gpt4 book ai didi

javascript - 如何在 Javascript 代码中声明我的模式

转载 作者:行者123 更新时间:2023-11-28 05:49:49 25 4
gpt4 key购买 nike

实际上我想在 box-click 上设置模态,所以我将 onclick 标签放在 box 标签中,但之后我的模态没有出现......实际上,我为单个框传递了唯一 ID,这很好,但模态框没有出现......所以请帮助我

   <?php

include("connect.php");
$query="SELECT * FROM `orders`";
$filter_Result=mysqli_query($con,$query);

$count=0;
while($row = mysqli_fetch_array($filter_Result)){
$count++;
$boxid = $count;

echo "<div class='block'>";



echo "<div class='boxed' id=$boxid onclick='myFunction($boxid)'>";
"<button id='$boxid'>Open Modal</button>";

"<div id='$boxid' class='modal'>";

"<div class='modal-content'>";
"<span class='close'>x</span>";
"<p>Some text in the Modal..</p>";
"</div>";

"</div>";
echo "<div id='container'>";


echo "<td>" . $row['id'] . "</td>" ."<br>";
echo "<td>" . $row['status'] . "</td>"."<br>";
echo "<td>" . $row['created_date'] . "</td>"."<br>";
echo "<td>" . $row['uid'] . "</td>"."<br>"."<br>"."<br>"."<br>";

echo "</div>";


echo "</div>";


echo "</div>";


}

?>
<script>
function myFunction(id) {
//modal = document.getElementById($id);
//window.alert(modal);

// Get the button that opens the modal
//var btn = document.getElementById("myBtn");
window.alert(id);
document.getElementById(id).innerHTML = Date();

}

</script>

最佳答案

替换这段代码:

<?php

include("connect.php");
$query="SELECT * FROM `orders`";
$filter_Result=mysqli_query($con,$query);

$count=0;
while($row = mysqli_fetch_array($filter_Result)){
$count++;
$boxid = $count;

echo "<div class='block'>";



echo "<div class='boxed'>";
"<button onclick='myFunction($boxid)'>Open Modal</button>";

"<div id='$boxid' class='modal'>";

"<div class='modal-content'>";
"<span class='close'>x</span>";
"<p>Some text in the Modal..</p>";
"</div>";

"</div>";
echo "<div id='container'>";


echo "<td>" . $row['id'] . "</td>" ."<br>";
echo "<td>" . $row['status'] . "</td>"."<br>";
echo "<td>" . $row['created_date'] . "</td>"."<br>";
echo "<td>" . $row['uid'] . "</td>"."<br>"."<br>"."<br>"."<br>";

echo "</div>";


echo "</div>";


echo "</div>";


}

?>
<script>
function myFunction(id) {
modal = document.getElementById($id);
window.alert(modal);
}
</script>

关于javascript - 如何在 Javascript 代码中声明我的模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37406191/

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