簡體   English   中英

如何創建表,當用戶提交表單時在其中填充行

[英]How to create a table, in which rows are filled in when a user submits a form

我想創建兩個單獨的頁面,一個頁面上帶有html表單,另一個頁面上帶有表。 當用戶輸入數據並提交表單時,我希望信息顯示在表中。

我需要使用Javascript或PHP還是都不使用它來實現此目的。

任何幫助,將不勝感激,

這是表:

   <table border='1px' >

            <tr>
            <th>Location</th>
            <th>Time</th>
            <th>Date</th>
            </tr>
            <tr>
            <td  id='location1'>info</td>
            <td id="time1">info</td>
            <td id="date1">info</td>

            </tr>  
            <tr>
            <td id="location2">info</td>
            <td id="time2">info</td>
            <td id="date2">info</td>

            </tr>
            <tr>
            <td id="location3">info</td>
            <td id="time3">info</td>
            <td id="date3">info</td>
            </tr>
</table>

形式如下:

<form action="" method="post">
    Enter Location<input type="text" name="location" id="location" /><br />

    Time  <input type="text" name="" id="type" /><br />

    Date<input type="text" name="pitch" id="pitch" /><br />

    <input type="submit" name="submit" value="submit" /><br />
 </form>

您可以使用php或javascript-php會更簡單,恕我直言。 最簡單的代碼示例如下所示:

<table border='1px' >

            <tr>
            <th>Location</th>
            <th>Time</th>
            <th>Date</th>
            </tr>
            <tr>
            <td  id='location1'><?php isset($_POST['location']) ? $_POST['location'] : '' ?></td>
            <td id="time1"><?php isset($_POST['time']) ? $_POST['time'] : '' ?></td>
            <td id="date1"><?php isset($_POST['pitch']) ? $_POST['pitch'] : '' ?></td>

            </tr>  
</table>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM