简体   繁体   English

你如何删除以前的回声/表格 PHP

[英]how do you delete a previous echo / form PHP

I am currently working on a project that controls output through an EOT.我目前正在开发一个通过 EOT 控制 output 的项目。 But when I want to request a new control he puts the new control under the previous control (or under the previous echo).但是当我想请求一个新控件时,他会将新控件置于先前的控件之下(或之前的回显之下)。 Now I am trying to delete or overwrite the previous echo.现在我正在尝试删除或覆盖以前的回声。 I know there are already several topics about it, but this is not what I am looking for.我知道已经有几个关于它的主题,但这不是我想要的。 I want to delete my previous echo's when I request my new check through my button.当我通过我的按钮请求我的新支票时,我想删除我以前的回声。 I've already tried with "OB_clean" and "OB_Flush" working in all possible places, but this won't work我已经尝试过在所有可能的地方使用“OB_clean”和“OB_Flush”,但这不起作用

Thx!谢谢!

<div class="content">
    <div id="myForm" class="container-fluid">
        <form id="myForm" method="POST">
            <p class="Titel">Controles opvragen:</p>
            <div class="form-group">
                <div class="form-group">
                    <button name="Controle1" type="submit" class="btn btn-primary" value="1">Controle 1</button>
                    <button name="Controle2" type="submit" class="btn btn-primary" value="2">Controle 2</button>
                    <button name="Controle3" type="submit" class="btn btn-primary" value="3">Controle 3</button>
                    <button name="Controle4" type="submit" class="btn btn-primary" value="4">Controle 4</button>
                    <button name="Controle5" type="submit" class="btn btn-primary" value="5">Controle 5</button>
                </div>
                <div>
                    <?php
                        $uri = $_SERVER['REQUEST_URI'];
                        if (isset($_POST['Controle1'])) 
                        {
                        
                            $checkpointID = $_POST['Controle1'];
                            FormBuilder($checkpointID) ; 
                        }
                        if (isset($_POST['Controle2'])) 
                        {
                          
                            $checkpointID = $_POST['Controle2'];
                            FormBuilder($checkpointID);      
                        }
                        if (isset($_POST['Controle3'])) 
                        {
                            $checkpointID = $_POST['Controle3'];
                            FormBuilder($checkpointID);  
                        }
                        if (isset($_POST['Controle4'])) 
                        {
                            $checkpointID = $_POST['Controle4'];
                            FormBuilder($checkpointID); 
                        }
                        if (isset($_POST['Controle5'])) 
                        {
                            $checkpointID = $_POST['Controle5'];
                            FormBuilder($checkpointID); 
                        }
                        if (isset($_POST['Controle6'])) 
                        {
                            $checkpointID = $_POST['Controle6'];
                            FormBuilder($checkpointID);
                        }
                    ?>
                </div>
            </div>
        </form>
    </div>
</div>

在此处输入图像描述

Your code has a form so the page refreshes and clears everytime you click a button and this question has no sense.您的代码有一个表单,因此每次单击按钮时页面都会刷新和清除,这个问题毫无意义。 Anyway, if thats what you need, one way around can be to use jquery to clear.无论如何,如果这就是你需要的,一种方法是使用 jquery 来清除。 You can give the div an id and use simple jquery to clear everything inside the element.您可以给 div 一个 id 并使用简单的 jquery 来清除元素内的所有内容。 You can echo the jquery code or you can create a function to call when you need with an echo.您可以回显 jquery 代码,或者您可以创建 function 以在需要时通过回显调用。 There is an example of the code.有一个代码示例。

<script>
     function cleardiv(){
        $("#div").html("");
    }
 </script>
 <div class="content">
   <div id="myForm" class="container-fluid">
    <form id="myForm" method="POST">
        <p class="Titel">Controles opvragen:</p>
        <div class="form-group">
            <div class="form-group">
                <button name="Controle1" type="submit" class="btn btn-primary" value="1">Controle 1</button>
                <button name="Controle2" type="submit" class="btn btn-primary" value="2">Controle 2</button>
                <button name="Controle3" type="submit" class="btn btn-primary" value="3">Controle 3</button>
                <button name="Controle4" type="submit" class="btn btn-primary" value="4">Controle 4</button>
                <button name="Controle5" type="submit" class="btn btn-primary" value="5">Controle 5</button>
            </div>
            <div id="div">
                <?php
                    echo "<script> cleardiv() </script>";
                    $uri = $_SERVER['REQUEST_URI'];
                    if (isset($_POST['Controle1'])) 
                    {
                    
                        $checkpointID = $_POST['Controle1'];
                        FormBuilder($checkpointID) ; 
                    }
                    if (isset($_POST['Controle2'])) 
                    {
                      
                        $checkpointID = $_POST['Controle2'];
                        FormBuilder($checkpointID);      
                    }
                    if (isset($_POST['Controle3'])) 
                    {
                        $checkpointID = $_POST['Controle3'];
                        FormBuilder($checkpointID);  
                    }
                    if (isset($_POST['Controle4'])) 
                    {
                        $checkpointID = $_POST['Controle4'];
                        FormBuilder($checkpointID); 
                    }
                    if (isset($_POST['Controle5'])) 
                    {
                        $checkpointID = $_POST['Controle5'];
                        FormBuilder($checkpointID); 
                    }
                    if (isset($_POST['Controle6'])) 
                    {
                        $checkpointID = $_POST['Controle6'];
                        FormBuilder($checkpointID);
                    }
                ?>
            </div>
        </div>
    </form>
</div>

I know that probably this is not the right way to do it but it can be an option.我知道这可能不是正确的方法,但它可以是一种选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM