【问题标题】:How to transfer data from tables to web forms?如何将数据从表格传输到 Web 表单?
【发布时间】:2017-11-22 11:03:19
【问题描述】:

我有一个表格,通过字典列表显示信息。

这是程序:

  <div class = "col-md-8" >
          <table class="table table-bordered table-striped table-hover">


            <thead> <!-- En-tête du tableau -->
              <tr>
                <th> Host Name </th>
                <th> Hardware </th>
                <th> Fixed-Address </th>
                <th> Comment </th>
              <tr>
            </thead>

            <tbody> <!-- Corps du tableau -->
              {% for item in items %}
                <tr id="confirm">
                {% for key in  [ 'host','hardware','fixed_address','comment' ] %}
                  <td> {{ item[key].decode('utf-8') }}</td>
                {% endfor %}
                </tr>
              {% endfor %}
            </tbody>
         </table>
      </div>

我想做的是能够修改它或添加一个新条目,这不是我要在这里问的,因为在此之前我需要执行以下操作:

基本上,我需要让每一行都充当一个链接,当我点击它(行)时,我应该被重定向到带有网络表单的网页,这些网络表单将填充来自表格单元格的数据.

我该怎么做?先谢谢了。

【问题讨论】:

    标签: python html flask


    【解决方案1】:

    做这样的事情。

    <thead> <!-- En-tête du tableau -->
              <tr>
                <th> Host Name </th>
                <th> Hardware </th>
                <th> Fixed-Address </th>
                <th> Comment </th>
                <th> View </th>
              <tr>
            </thead>
           <tbody> <!-- Corps du tableau -->
              {% for item in items %}
                <tr id="confirm">
                {% for key in  [ 'host','hardware','fixed_address','comment' ] %}
                  <td> {{ item[key].decode('utf-8') }}</td>
                {% endfor %}
              <a href="{{ url_for(<Function to navigate to>) }}">View</a>
                </tr>
              {% endfor %}
               </tbody>
         </table>
      </div>
    

    url_for 里面的那个函数应该是显示数据的函数,应该渲染页面来显示数据。

    【讨论】:

    • 您的链接只会将我发送到另一个页面而无需执行任何操作,在它之上它会多次显示“查看”。
    猜你喜欢
    • 2023-03-05
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 2014-03-06
    • 2020-09-29
    • 2018-04-05
    • 2023-01-10
    • 1970-01-01
    相关资源
    最近更新 更多