Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.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
Javascript 提交表单时隐藏DIV_Javascript_Php_Jquery_Html_Forms - Fatal编程技术网

Javascript 提交表单时隐藏DIV

Javascript 提交表单时隐藏DIV,javascript,php,jquery,html,forms,Javascript,Php,Jquery,Html,Forms,我开发了一个PHP表单,它使用mySQL查询自动提交数据并显示数据。我有一个div,我需要在自动提交表单时隐藏它。由于页面正在刷新,隐藏的jQuery正在丢失 表格代码: <div id="map"><iframe src="url oof source" width="700" height="300" frameborder="0"></iframe></div><br /> <div> <div class=

我开发了一个PHP表单,它使用mySQL查询自动提交数据并显示数据。我有一个div,我需要在自动提交表单时隐藏它。由于页面正在刷新,隐藏的jQuery正在丢失

表格代码:

<div id="map"><iframe src="url oof source" width="700" height="300" frameborder="0"></iframe></div><br />

<div>

<div class="dropdown">
<span style="color:#131787; font-size:2em; font-family:Arial, Helvetica, sans-serif;;">some text</span>
</div>

<div >
<form method="get" action="<?php echo $url = basename($_SERVER['PHP_SELF']); ?>">
<select name="country" onchange='this.form.submit()'> 
    <?php $result= mysql_query('Query'); ?> 
<option value="x" selected>Select your destination</option>
    <?php while($row= mysql_fetch_assoc($result)) { ?> 
        <option value="<?php echo htmlspecialchars($row['country']);?>" > 
            <?php echo htmlspecialchars($row['country']); ?> 
        </option> 
    <?php } ?> 
<input type="hidden" name="action" value="submit" /><br /><br/>
</select>
</form>
</div>

</div>

一些文本 选择你的目的地
您可以将其添加到
isset($\u GET['action'])
条件中,如:

<?php
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");


    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    echo '<script>$(document).ready(function() { $(\'#map\').hide(); });</script>';
}
?>

但是,这可能更好:

<?php
$display = "block";
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");

    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    $display = "none";
}
?>

然后,当您显示div时,您可以使用:

<div id="map" style="display: <?php echo $display; ?>">...</div>

您可以将其添加到
isset($\u GET['action'])
条件中,如:

<?php
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");


    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    echo '<script>$(document).ready(function() { $(\'#map\').hide(); });</script>';
}
?>

但是,这可能更好:

<?php
$display = "block";
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");

    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    $display = "none";
}
?>

然后,当您显示div时,您可以使用:

<div id="map" style="display: <?php echo $display; ?>">...</div>

您可以将其添加到
isset($\u GET['action'])
条件中,如:

<?php
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");


    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    echo '<script>$(document).ready(function() { $(\'#map\').hide(); });</script>';
}
?>

但是,这可能更好:

<?php
$display = "block";
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");

    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    $display = "none";
}
?>

然后,当您显示div时,您可以使用:

<div id="map" style="display: <?php echo $display; ?>">...</div>

您可以将其添加到
isset($\u GET['action'])
条件中,如:

<?php
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");


    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    echo '<script>$(document).ready(function() { $(\'#map\').hide(); });</script>';
}
?>

但是,这可能更好:

<?php
$display = "block";
if (isset($_GET["action"])) {
    $var1 = $wpdb - > get_results("Query");
    $var2 = $wpdb - > get_results("Query");
    $var3 = $wpdb - > get_results("Query");
    $var4 = $wpdb - > get_results("Query");

    if (empty($var1)) {
        echo '<h3 style="color:red;">No Results</h3>';
    } else {
        foreach($var11 as $var1) {
            foreach($var22 as $var2) {
            }
        }
    }
    $display = "none";
}
?>

然后,当您显示div时,您可以使用:

<div id="map" style="display: <?php echo $display; ?>">...</div>
这里有一个错误:

<script>$(document).ready(function() { $('#map').hide(); **}**</script>
$(文档).ready(函数(){$('#映射').hide();**}**
代码应为:

<script>$(document).ready(function() { $('#map').hide(); **});**</script>
$(document).ready(函数(){$('#map').hide();**})**
这里有一个错误:

<script>$(document).ready(function() { $('#map').hide(); **}**</script>
$(文档).ready(函数(){$('#映射').hide();**}**
代码应为:

<script>$(document).ready(function() { $('#map').hide(); **});**</script>
$(document).ready(函数(){$('#map').hide();**})**
这里有一个错误:

<script>$(document).ready(function() { $('#map').hide(); **}**</script>
$(文档).ready(函数(){$('#映射').hide();**}**
代码应为:

<script>$(document).ready(function() { $('#map').hide(); **});**</script>
$(document).ready(函数(){$('#map').hide();**})**
这里有一个错误:

<script>$(document).ready(function() { $('#map').hide(); **}**</script>
$(文档).ready(函数(){$('#映射').hide();**}**
代码应为:

<script>$(document).ready(function() { $('#map').hide(); **});**</script>
$(document).ready(函数(){$('#map').hide();**})**

你就不能这样做吗

 <?php
if(isset($_GET["action"])) { 
$var1= $wpdb->get_results("Query");
$var2= $wpdb->get_results("Query");
$var3= $wpdb->get_results("Query");
$var4= $wpdb->get_results("Query");
$vis="display:none;";


if (empty($var1))
{ echo '<h3 style="color:red;">No Results</h3>';} 
else 
{foreach ( $var11 as $var1 ) {
    foreach ( $var22 as $var2 ){
}}}else
{
  $vis="";
}
{


<div>

<div class="dropdown">
<span style="color:#131787; font-size:2em; font-family:Arial, Helvetica, sans-serif;;">some text</span>
</div>

<div >
<form method="get" action="<?php echo $url = basename($_SERVER['PHP_SELF']); ?>">
<select name="country" onchange='this.form.submit()'> 
    <?php $result= mysql_query('Query'); ?> 
<option value="x" selected>Select your destination</option>
    <?php while($row= mysql_fetch_assoc($result)) { ?> 
        <option value="<?php echo htmlspecialchars($row['country']);?>" > 
            <?php echo htmlspecialchars($row['country']); ?> 
        </option> 
    <?php } ?> 
<input type="hidden" name="action" value="submit" /><br /><br/>
</select>
</form>
</div>

</div>
 <?php } ?>

一些文本
选择你的目的地

你就不能这样做吗

 <?php
if(isset($_GET["action"])) { 
$var1= $wpdb->get_results("Query");
$var2= $wpdb->get_results("Query");
$var3= $wpdb->get_results("Query");
$var4= $wpdb->get_results("Query");
$vis="display:none;";


if (empty($var1))
{ echo '<h3 style="color:red;">No Results</h3>';} 
else 
{foreach ( $var11 as $var1 ) {
    foreach ( $var22 as $var2 ){
}}}else
{
  $vis="";
}
{


<div>

<div class="dropdown">
<span style="color:#131787; font-size:2em; font-family:Arial, Helvetica, sans-serif;;">some text</span>
</div>

<div >
<form method="get" action="<?php echo $url = basename($_SERVER['PHP_SELF']); ?>">
<select name="country" onchange='this.form.submit()'> 
    <?php $result= mysql_query('Query'); ?> 
<option value="x" selected>Select your destination</option>
    <?php while($row= mysql_fetch_assoc($result)) { ?> 
        <option value="<?php echo htmlspecialchars($row['country']);?>" > 
            <?php echo htmlspecialchars($row['country']); ?> 
        </option> 
    <?php } ?> 
<input type="hidden" name="action" value="submit" /><br /><br/>
</select>
</form>
</div>

</div>
 <?php } ?>

一些文本
选择你的目的地

你就不能这样做吗

 <?php
if(isset($_GET["action"])) { 
$var1= $wpdb->get_results("Query");
$var2= $wpdb->get_results("Query");
$var3= $wpdb->get_results("Query");
$var4= $wpdb->get_results("Query");
$vis="display:none;";


if (empty($var1))
{ echo '<h3 style="color:red;">No Results</h3>';} 
else 
{foreach ( $var11 as $var1 ) {
    foreach ( $var22 as $var2 ){
}}}else
{
  $vis="";
}
{


<div>

<div class="dropdown">
<span style="color:#131787; font-size:2em; font-family:Arial, Helvetica, sans-serif;;">some text</span>
</div>

<div >
<form method="get" action="<?php echo $url = basename($_SERVER['PHP_SELF']); ?>">
<select name="country" onchange='this.form.submit()'> 
    <?php $result= mysql_query('Query'); ?> 
<option value="x" selected>Select your destination</option>
    <?php while($row= mysql_fetch_assoc($result)) { ?> 
        <option value="<?php echo htmlspecialchars($row['country']);?>" > 
            <?php echo htmlspecialchars($row['country']); ?> 
        </option> 
    <?php } ?> 
<input type="hidden" name="action" value="submit" /><br /><br/>
</select>
</form>
</div>

</div>
 <?php } ?>

一些文本
选择你的目的地

你就不能这样做吗

 <?php
if(isset($_GET["action"])) { 
$var1= $wpdb->get_results("Query");
$var2= $wpdb->get_results("Query");
$var3= $wpdb->get_results("Query");
$var4= $wpdb->get_results("Query");
$vis="display:none;";


if (empty($var1))
{ echo '<h3 style="color:red;">No Results</h3>';} 
else 
{foreach ( $var11 as $var1 ) {
    foreach ( $var22 as $var2 ){
}}}else
{
  $vis="";
}
{


<div>

<div class="dropdown">
<span style="color:#131787; font-size:2em; font-family:Arial, Helvetica, sans-serif;;">some text</span>
</div>

<div >
<form method="get" action="<?php echo $url = basename($_SERVER['PHP_SELF']); ?>">
<select name="country" onchange='this.form.submit()'> 
    <?php $result= mysql_query('Query'); ?> 
<option value="x" selected>Select your destination</option>
    <?php while($row= mysql_fetch_assoc($result)) { ?> 
        <option value="<?php echo htmlspecialchars($row['country']);?>" > 
            <?php echo htmlspecialchars($row['country']); ?> 
        </option> 
    <?php } ?> 
<input type="hidden" name="action" value="submit" /><br /><br/>
</select>
</form>
</div>

</div>
 <?php } ?>

一些文本
选择你的目的地



@HeroFTime它位于我提供的第一个代码区域的第一行代码中。您可能正在文档中加载jQuery?如何确定是否运行此脚本?所有这些都未显示在您的帖子中。您尚未关闭document ready函数?请尝试在最后一个}之后添加a)在@HeroFTime之前,它位于我提供的第一个代码区域的第一行代码中。可能您正在文档中加载jQuery?如何确定是否运行此脚本?所有这些都不会显示在您的帖子中。您尚未关闭document ready函数?请尝试在最后一个}之后添加a)在@HeroFTime之前,它位于我提供的第一个代码区域的第一行代码中。可能您正在文档中加载jQuery?如何确定是否运行此脚本?所有这些都不会显示在您的帖子中。您尚未关闭document ready函数?请尝试在最后一个}之后添加a)在@HeroFTime之前,它位于我提供的第一个代码区域的第一行代码中。可能您正在文档中加载jQuery?如何确定是否运行此脚本?所有这些都没有显示在您的帖子中。您还没有关闭document ready函数?请尝试在第二个选项的上一个}之后添加a)。但第一个选项是不正确的,因为我们无法确保此输出位于正确的位置html@DKasiponvic我实现了你的上述建议,但由于某种原因,这仍然不起作用,并且隐藏了问题。你尝试了哪一个?如果它是第一个,那么应该确保它在jquery导入之后。第二个应该无论如何都能用,而且最好还是用它,所以试试吧。设法让它在一些脚本位置上工作。非常感谢你的帮助!!投票赞成第二种选择。但第一个选项是不正确的,因为我们无法确保此输出位于正确的位置html@DKasiponvic我实现了你的上述建议,但由于某种原因,这仍然不起作用,并且隐藏了问题。你尝试了哪一个?如果它是第一个,那么应该确保它在jquery导入之后。第二个应该无论如何都能用,而且最好还是用它,所以试试吧。设法让它在一些脚本位置上工作。非常感谢你的帮助!!投票赞成第二种选择。但第一个选项是不正确的,因为我们无法确保此输出位于正确的位置html@DKasiponvic我实现了你的上述建议,但由于某种原因,这仍然不起作用,并且隐藏了问题。你尝试了哪一个?如果它是第一个,那么应该确保它在jquery导入之后。第二个应该无论如何都能用,而且最好还是用它,所以试试吧。设法让它在一些脚本位置上工作。非常感谢你的帮助!!投票赞成第二种选择。但第一个选项是不正确的,因为我们无法确保此输出位于正确的位置html@DKasiponvic我实现了你的上述建议,但由于某种原因,这仍然不起作用,并且隐藏了问题。你尝试了哪一个?如果它是第一个,那么应该确保它在jquery导入之后。第二个应该无论如何都能用,而且最好还是用它,所以试试吧。设法让它在一些脚本位置上工作。非常感谢你的帮助!!我已经实现了上面的更改,但是刷新时这并没有使div隐藏。我可以得到该页面的URL吗?我已经实现了上面的更改,但是刷新时这并没有使div隐藏。我可以得到