gpt4 book ai didi

javascript - 表单提交后如何保持动态下拉菜单的值保持选中状态?

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

请帮我在提交表单后显示所选的电子邮件。请查看下面提到的代码:

<?php
$query= mysqli_query($conn," SELECT email FROM register");
$options="";
$result=mysqli_fetch_assoc($query);
if(mysqli_num_rows($query) >0)
{
while($row=mysqli_fetch_array($query))
{
$options = $options."<option>$row[0]</option>";
}
}
?>
<select name="email" id="email">
<option value="" disabled="" selected="">SELECT EMAIL</option>
<?php echo $options;?>
</select>

最佳答案

    <select name="email" id="email">
<option value="" disabled="" selected="">SELECT EMAIL</option>
<?php
$query= mysqli_query($conn," SELECT email FROM register");
$result=mysqli_fetch_assoc($query);
if(mysqli_num_rows($query) >0)
{
while($row=mysqli_fetch_array($query))
{
echo "<option value='<?=$row[0]?>'><?= $row[0]?></option>";
}
}
?>
</select>

关于javascript - 表单提交后如何保持动态下拉菜单的值保持选中状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54400390/

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