Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当div#firstpage设置为隐藏时,为什么我的div#firstpage显示在我的div#lastpage上?_Php_Html - Fatal编程技术网

Php 当div#firstpage设置为隐藏时,为什么我的div#firstpage显示在我的div#lastpage上?

Php 当div#firstpage设置为隐藏时,为什么我的div#firstpage显示在我的div#lastpage上?,php,html,Php,Html,我断断续续地编写这段PHP和HTML代码已经一周了,试图弄清楚为什么当#firstpage的div id设置为隐藏时,我的#firstpage的div id会显示在我的div id#lastpage上?代码应该显示第一页,当用户点击“选择”按钮时,第一页应该隐藏,第二页应该显示。显示第二页后,用户点击“选择”按钮,第二页应隐藏,最后一页应显示 正在发生的事情发生在最后一页,第一页和最后一页都显示出来 这是我的密码: <?php $first = ""; if (isse

我断断续续地编写这段PHP和HTML代码已经一周了,试图弄清楚为什么当#firstpage的div id设置为隐藏时,我的#firstpage的div id会显示在我的div id#lastpage上?代码应该显示第一页,当用户点击“选择”按钮时,第一页应该隐藏,第二页应该显示。显示第二页后,用户点击“选择”按钮,第二页应隐藏,最后一页应显示

正在发生的事情发生在最后一页,第一页和最后一页都显示出来

这是我的密码:

<?php
$first = "";
if (isset($_POST[submit])){
$first = "hide";
}

$second = "";
if (isset($_POST[submit8])){
$second = "hide";

}
var_dump($first);
var_dump($second);
var_dump($first!="");
var_dump($second!="");

if (isset($_POST[submit9])){
}
?>

<html>
<link rel="stylesheet" type="text/css" href="style/style.css" />
<style>
#formState { width: 35%;}
#formCounty { width: 35%;}
    
.tg  {border-collapse:collapse;border-spacing:0;border-color:#aaa;}
.tg td{font-family:Arial, sans-serif;font-size:12px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#aaa;color:#333;background-color:#fff;}
.tg th{font-family:Arial, sans-serif;font-size:12px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#aaa;color:#fff;background-color:#f38630;}
.tg .tg-cly1{text-align:center;vertical-align:middle}
.tg .tg-0lax{text-align:center;vertical-align:top}
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dependent-dropdown/1.4.9/js/dependent-dropdown.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css">
<body>
<div id="firstpage">    
<form method='POST'>
    <h4>Hello and Welcome to our Players Looking for Teams to Play on!</h4>
    <h4>We have to ask a few questions</h4>
    
    <h6>Please select the State you would like to play in:</h6>
    <p>Select State
    <input type="submit" name="submit" value="Select" Style = "color:white; background-color:blue" required>        
</form>
</div>
<div id="secondpage">
<form method='POST'>
    <h4>Hello and Welcome to our Players Looking for Teams to Play on!</h4>
    <h4>Now, what county will you play out of?</h4>
    
    <h6>Please select the County you would like to play in:</h6>
    <input type="submit" name="submit8" value="Select" Style = "color:white; background-color:blue" required>
</form>
</div>  
<div id="lastpage">
<form method="POST">
    <h4>Hello and Welcome to our Players Looking for Teams to Play on!</h4>
    <h4>All Done!! This is how Captains will see your listing.</h4>
<input type="submit" name="submit9" value="Submit Listing" Style = "color:white; background-color:blue" required>
</form>
</div>

</body>
<?php
if($first!=""){
    ?>
<script type="text/javascript">
$("#firstpage").hide(); 
$("#secondpage").show();
$("#lastpage").hide();
     </script>
<?php
}elseif($second!=""){
    ?>
<script type="text/javascript">
$("#firstpage").hide(); 
$("#secondpage").hide();
$("#lastpage").show();
     </script>
<?php
}else{
    ?>
<script type="text/javascript">
$("#firstpage").show();
$("#secondpage").hide();
$("#lastpage").hide();
</script>
<?php
}
?>
<script type="text/javascript">
$(".chosen").chosen();
    </script>

</html>

#formState{宽度:35%;}
#formCounty{宽度:35%;}
.tg{边框折叠:折叠;边框间距:0;边框颜色:#aaa;}
.tg td{字体系列:Arial,无衬线;字体大小:12px;填充:10px 5px;边框样式:实心;边框宽度:1px;溢出:隐藏;分词:正常;边框颜色:#aaa;颜色:#333;背景颜色:#fff;}
.tg th{字体系列:Arial,无衬线;字体大小:12px;字体重量:正常;填充:10px 5px;边框样式:实心;边框宽度:1px;溢出:隐藏;分词:正常;边框颜色:#aaa;颜色:#fff;背景颜色:#f38630;}
.tg.tg-cly1{文本对齐:中间;垂直对齐:中间}
.tg.tg-0lax{文本对齐:中心;垂直对齐:顶部}
大家好,欢迎来到我们寻找球队的球员!
我们得问几个问题
请选择要在其中播放的状态:
选择状态
大家好,欢迎来到我们寻找球队的球员!
现在,你将在哪个县比赛?
请选择您想在其中玩的县:
大家好,欢迎来到我们寻找球队的球员!
全部完成!!这就是船长们如何看待你的名单。
$(“#首页”).hide();
$(“#第二页”).show();
$(“#最后一页”).hide();
$(“#首页”).hide();
$(“#第二页”).hide();
$(“#最后一页”).show();
$(“#首页”).show();
$(“#第二页”).hide();
$(“#最后一页”).hide();
$(“.selected”).selected();

非常感谢您的帮助。

如果您要提交表单,使用JS显示或隐藏div有什么意义?为什么不在绘制每一页之前使用
switch()
来决定显示哪一页呢?不久前,我正在寻找一种在一页上显示多个表单的方法。我向StackOverflow提交了这个问题,并继续沿着这条路走下去@droopsnoot我使用开关()进行了调整。你的建议非常有效。