【问题标题】:Anchor tag using row id in bottlepy to-do tutorial在 Bottlepy 待办事项教程中使用行 ID 锚定标签
【发布时间】:2017-02-08 16:21:57
【问题描述】:

这是一个模板,它采用数据库表的行和不同字段中的字段。我是新手。

  <table border="0" class="table table-hover">
        %for row in rows:
          <tr>
          %for col in row:
            <td>
              <b>
                {{col}}
              </b>
            </td>
          %end
          </tr>
        %end
        </table>

我想在上面的每一行中使用带有特定 url 和查询 id 的锚标记。我该怎么做?

即http://domain.com/edit/行号

【问题讨论】:

    标签: python python-2.7 bottle


    【解决方案1】:

    你的意思是这样的吗?

    <!doctype html>
    <table border="0" class="table table-hover">
    %for row in rows:
      <tr>
      %for i in range(len(row)):
        <td>
         %# assuming you want to display col == 3 to as a link
         %# and the row id is in col == 0
         %if i == 3:
         <a href=" http://domain.com/edit/{{row[0]}}">{{row[i]}}</a>
         %else:
          <b>{{row[i]}}</b>
          %end
        </td>
      %end
      </tr>
    %end
    </table>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      • 2020-09-02
      • 2018-03-22
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多