[英]Stuck in endless loop while creating buttons
I'm trying to create a website, where I can insert products with a button
. 我正在尝试创建一个网站,可以在其中插入带有
button
产品。
So for now I got one button
which creates one div
as a product box. 因此,现在我得到了一个
button
,该button
创建了一个div
作为产品框。 When the button
is clicked it becomes invisible, under this I can see the div
now; 单击该
button
,它变得不可见,在此之下我现在可以看到div
; and under the div
, there's the next button
which should be able to create one more div
s (always the same way). 在
div
,还有一个下一个button
,它应该能够再创建一个div
(始终以相同的方式)。
The problem is that I can't find any solution to do that. 问题是我找不到解决方案。 I always land in an endless loop.
我总是陷入无尽的循环。
If you're wondering about the mailer, the idea for the first step is, to send a mail as newsletter for every created product. 如果您对邮件程序感到疑惑,第一步的想法是,为每个已创建的产品发送邮件作为时事通讯。
Here's my code: 这是我的代码:
<?php
echo "<form action='index.php' method='GET'>";
echo "<input type='submit' name='insert' id='insert' value='INSERT'>";
echo "</form>";
if ($_GET["insert"]) {
echo " <script language='JavaScript'> ";
echo "";
echo " ";
echo " document.getElementById('insert').style.visibility='hidden' ";
echo "";
echo "</script>";
echo " <div class='article'>";
echo "<h2>product</h2>";
echo "<p>";
echo "EXAMPLE";
echo "</p>";
echo "</div> ";
echo "<form action='index.php' method='GET'>";
echo "<input type='submit' name='ins ert' id='insert' value='INSERT'>";
echo "</form>";
//send mail
$message = "hello TEST!";
for ($i = 0; $i < $z; $i++) {
mail('' . $res[$i] . '', 'Newsletter', $message);
}
}
?>
You are hiding an "id=insert" item, and then creating a second "id=insert" item. 您将隐藏“ id =插入”项,然后创建第二个“ id =插入”项。 So you get 2 identical id, which is not good.
所以你得到两个相同的ID,这是不好的。 You should "remove" the "id=insert" rather than "hide" it.
您应该“删除”“ id = insert”,而不是“隐藏”它。 jquery may help you on that.
jQuery可能会帮助您。
(And so you may not need to remove the "id=insert" item, but rather "add" a new div "after" your last product). (因此,您可能不需要删除“ id = insert”项,而只需在最后一个产品之后“添加”新的div)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.