【发布时间】:2020-06-18 20:06:59
【问题描述】:
我有一张表,其中包含五十家公司(项目)的列表,旁边有一个按钮。我想从单击用户的表中发送公司名称。
index.html的代码:
<table class="table table-striped table-dark" cellspacing="0">
<thead class="bg-info">
<tr>
<th>Company's Symbol</th>
<th>Current Price</th>
<th>View Current chart</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{% for a,b in stocks %}
<tr>
<th scope="row" class="comp_name">{{ a }}</th>
<td>{{ b }}</td>
<td>
<input type="submit" class="btn graph-btn" name="_graph" value="View Graph">
</td>
<td>
<input type="submit" class="btn predict-btn" name="_predict" value="Predict Closing Price">
</td>
</tr>
{% endfor %}
</tbody>
</table>
不同的 URL 有两个按钮。就像用户在.graph-btn 上点赞时一样,它会转到不同的 URL。
帮助。
【问题讨论】:
-
你是什么意思去不同的网址。您是否希望用户根据连续单击的按钮重定向到不同的页面?如果您希望用户重定向,您可以使用
<a>标记并将其设置为按钮。如果数据来自数据库,href应该可以通过 django url helpers 轻松构建
标签: javascript python jquery django ajax