【问题标题】:Preventing the user to re-open(click) a button after certain forms filled up防止用户在填写某些表格后重新打开(单击)按钮
【发布时间】:2017-07-29 20:00:18
【问题描述】:

我有一个用于我们的软件工程的管理信息系统。这就是我想要发生的事情。在我输入客户的基本信息后,他/她的记录(带ID)将显示在客户列表中。旁边是 2 个按钮,第一个按钮是“合同 1”,第二个按钮是“合同 2”。填写完任一合同后,我希望该按钮不可点击。

(另一种解释) 如果合同为空,请使“按钮”可点击,以便用户添加。但填满后,按钮就无法访问了。

我想你可能需要这个代码

<?php
                    include 'connect-db.php';
                ?>

                <table class="myTable" width="80%">


                    <th width="5%">Customer<br>Number</th>
                    <th>CRC</th>
                    <th>Name</th>
                    <th>Service<br>Contract</th>
                    <th>Chapel<br>Contract</th>
                </tr>
                <?php
                    $sql = "SELECT * FROM records ORDER BY CustomerNumber DESC LIMIT 5";
                    $result = mysql_query($sql);
                    if(mysql_num_rows($result) > 0 ){
                        while($row = mysql_fetch_assoc($result)){

                ?>
                            <tr>
                                <td><?=$row['CustomerNumber']?></td>
                                <td><?=$row['CRC']?></td>
                                <td><?=$row['Name']?></td>
                                <td>
                                    **<a href="editprocess-service.php?CustomerNumber=<?=$row['CustomerNumber']?>">Add</a>
                                </td>
                                <td>
                                    <a href="editprocess-chapel.php?CustomerNumber=<?=$row['CustomerNumber']?>">Add</a>
                                </td>**

                            </tr>
                <?php
                        }
                    }
                ?>
    </table>
    <br>        
    <a href="masterlist.php"><input type="button" value="New Record" style="margin-left: 785px;"></a>

粗体代码是我希望魔法发生的地方。提前谢谢!

【问题讨论】:

    标签: php forms href


    【解决方案1】:

    是的,只需禁用 onclick

    <button id="myBtn"onclick="myFunction()">My Button</button>
    

    【讨论】:

      【解决方案2】:

      如果您将合同信息存储在表格字段中,则可以使用 PHP 函数检查是否设置了值。

      if(isset($row['contract'])) {
           //echo disabled button
      } else {
           //eco interactable button
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-31
        • 2011-02-19
        • 2011-12-06
        • 1970-01-01
        • 2012-12-09
        • 1970-01-01
        • 2015-03-08
        • 2017-09-19
        相关资源
        最近更新 更多