2011-09-26 105 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的建议,非常感谢。 –