开发者

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

开发者 https://www.devze.com 2023-04-08 08:51 出处:网络
I\'m wanting to create two separate pages, one with a html form on it and the other with a table on it. When the user enters data and submits the form I want the information to be displayed in the tab

I'm wanting to create two separate pages, one with a html form on it and the other with a table on it. When the user enters data and submits the form I want the information to be displayed in the table.

Would I need to use Javascript or PHP or neither to achieve this.

Any help would be appreciated,

This is the table:

   <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>

This is the form:

<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>


you can use either php or javascript - php would be easier imho. the easiest code sample could look like that:

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消