2011-09-26 103 views
0

新手在這裏,我想創建兩個單獨的頁面,其中一個是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> 
+2

您只是希望將該信息放入網頁的表中,還是試圖將其存儲在SQL表中? – jprofitt

+0

是的,我只是想把這些信息放在網頁上的表格中,而不是SQL表格 –

回答

1

您可以使用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> 
+0

來顯示單個帖子數據這個解決方案是完美的,但要跟蹤該時間段的每個帖子邏輯將是不同的。 – punit

+1

感謝maialithar的建議,非常感謝。 –