HTML 和 php 按钮自定义显示信息


HTML & php buttons custom display information

我有一个任务列表。

最初,我显示所有这些。我想创建 2 个按钮,一个显示按日期排序的任务,另一个显示已通过的任务。

我该怎么做?我不知道如何制作一个按钮来做除了提交之外的任何其他事情。我正在考虑重定向到另一个"页面",但我不确定它是否有效。

<button type="button" name = 'display1' value="orderedDisplay">Order by date</button>
<button type="button" name = 'display2' value="passedTasks">Passed tasks</button>

            <table >
                <tr>
                    <a href="orderedbydate.php">Order by date</a>
                </tr>
                <tr>
                    <a href="pastevents.php">Display past events</a>
                </tr>
            </table>

但是我不知道如何"捕获"单击"按钮"键入按钮的事件。

为了让一个按钮做某事,你需要一些JavaScript,执行那个"某事":

<input type="button" name='display1' 
       onclick="callOrderByDate()" value="Order by date"/>

....
<script type="text/javascript">
   function callOrderByDate()
   {
        alert("I'm not ging to write the entire code here...");
   }
 ...
 </script>

样本