请我需要帮助我的问题,这是查看两个下拉选择在同一形式...我试图在我的代码中显示他们所有,但它只显示一个下拉选择,当我点击第一个下拉选择后,点击它会显示第二个下拉选择...有这个问题的任何解决方案?”
> here is my code
here is my code:
<head>
<script>
function showselect() {
$("#ff").submit();
}
$(document).ready(function()
{
$("#f").hide();
});
</script>
</head>
<body>
<form action="" method="POST" name="ff" id="ff">
<select id="" name="appname" class="s" >
<option value="" selected="true" disabled="disabled">date of appointment</option>
<?php
$query1 ="SELECT * FROM appo where p>0";
$result1 = $conn->query($query1);
if($result1->num_rows> 0){
while($option=$result1->fetch_assoc()){
$wed =$option['wed'];
$p =$option['p'];
?>
<option value="<?php echo $p; ?>" ><?php echo $wed; ?> </option>
<?php
}}
if($_POST['appname']){
$appname=$_POST['appname'];
?>
<script>
$(document).ready(function()
{
$("#f").show();
});
</script>
<?php
$sqh="SELECT * FROM form where i ='$appname'";
?>
</select>
<?php
$sqh2="SELECT * FROM appo where p ='$appname'";
$querys = $conn->query($sqh2);
while($row3=mysqli_fetch_array($querys,MYSQLI_ASSOC)){
$p=$row3['p'];
$wed=$row3['wed'];?>
<div class="ff" id="f">date of appointment :<?php echo $wed;?></div>
<?php
}
?>
<center>
<table class="table1" >
<?php
echo"<tr>";
?>
<th style="width:30px;">checking</th><th style="width:250px;">full name of employee</th><th style="width:200px;">careertitle</th><th style="width:250px;">work place</th>
<th style="width:200px;">type of require</th>
<th style="width:250px;">date of require</th>
<?php
echo"</tr>";
$query = $conn->query($sqh);
while($row2=mysqli_fetch_array($query,MYSQLI_ASSOC)){
$id=$row2['id'];
$full=$row2['fullname'];
$career=$row2['careertitle'];
$work=$row2['workplace'];
$statee=$row2['statee'];
$datee=$row2['datee'];
echo"<tr>";
?><td ><input type="checkbox" name="chck[]" id="check" onclick="showbutton()" value=<?php echo $id ?>/> </td>
<?php
echo"<td>$full</td>";
echo"<td>$career</td>";
echo"<td>$work</td>";
echo"<td>$datee</td>";
$sql4="SELECT * FROM cstatee where empid='$statee'";
$query4=mysqli_query($conn,$sql4);
while($row1=mysqli_fetch_array($query4,MYSQLI_ASSOC)){
$sname=$row1['sname'];
echo"<td>$sname</td>";
}
echo"</tr>";
}
}?>
</table>
<!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-->
<select id="" name="tname" class="s">
<option value="" selected="true" disabled="disabled">the full requirement</option>
<?php
$query ="SELECT * FROM cstatee";
$result = $conn->query($query);
if($result->num_rows> 0){
while($option=$result->fetch_assoc()){
$options =$option['sname'];
$id =$option['empid'];
?>
<option value="<?php echo $id; ?>" ><?php echo $options; ?> </option>
<?php
}}
if($_POST['tname']){
$tname=$_POST['tname'];
?>
<script>
$(document).ready(function()
{
$("#f").show();
});
</script>
<?php
$sqh="SELECT * FROM form where statee ='$tname'";
?>
</select>
<?php
$sqh2="SELECT * FROM cstatee where empid ='$tname'";
$querys = $conn->query($sqh2);
while($row3=mysqli_fetch_array($querys,MYSQLI_ASSOC)){
$empid=$row3['empid'];
$sname=$row3['sname'];?>
<div class="ff" id="f">type of require :<?php echo $sname;?></div>
<?php
}
?>
<center>
<table class="table1" >
<?php
echo"<tr>";
?>
<th style="width:30px;">checking </th><th style="width:250px;">full name of employee</th><th style="width:200px;">careertitle</th><th style="width:250px;">work place</th>
<th style="width:250px;">date of require</th>
<?php
echo"</tr>";
$query = $conn->query($sqh);
while($row2=mysqli_fetch_array($query,MYSQLI_ASSOC)){
$id=$row2['id'];
$full=$row2['fullname'];
$career=$row2['careertitle'];
$work=$row2['workplace'];
$datee=$row2['datee'];
echo"<tr>";
?><td ><input type="checkbox" name="chck[]" id="check" onclick="showbutton()" value=<?php echo $id ?>/> </td>
<?php
echo"<td>$full</td>";
echo"<td>$career</td>";
echo"<td>$work</td>";
echo"<td>$datee</td>";
echo"</tr>";
}
?>
<script>
$(document).ready(function(){
$("#update").slideToggle(1000);
});
</script>
</table>
<?php
}
?>
<input type="submit" name="update" id="update" value="editing" onClick="fup()" style="width:250px;height:80px;color:black;
background-image: linear-gradient(to bottom right,rgb(211, 106, 134),#3cb59d);background-repeat: no-repeat;margin-top:20px;margin-bottom:20px;">
<?php
if(isset($_POST['update'])){
if(isset($_POST['chck'])){
foreach($_POST['chck'] AS $selected){
$_SESSION['id']=$selected;?>
<script>
window.location.href="update.php";
</script>
<?php
}
}
}
?>
</form>
</body>````
1条答案
按热度按时间jtjikinw1#
1.确保你的代码中包含了jQuery库。如果没有,请在head部分中的现有脚本标记之前添加以下脚本标记:
1.在下拉列表中添加唯一的ID以区分它们。目前,这两个下拉列表的ID都为空。修改代码,为每个下拉列表提供唯一的ID:
1.最后,您对多个复选框使用了相同的ID(“check”)。ID在HTML文档中应该是唯一的。如果需要将相同的功能应用于多个复选框,请考虑改用类。