【发布时间】:2021-08-12 11:48:36
【问题描述】:
我对 HTML 完全陌生,我想知道是否有人可以帮助我。我尝试寻找与我类似的问题,但我没有找到与我正在寻找的东西非常相似的东西。对不起,如果这个问题对你来说似乎很愚蠢或容易,我正在努力学习!所以基本上我有一个可以在我的 HTML 文件中访问的 ID,我想通过一个表单将它发送到我的 python 函数,我已经设法为按钮执行此操作,但从来没有为表单执行此操作。这就是我如何通过按钮将我的 ID 发送到我的函数:
<a href="{{url_for('validate_comment', item_id=msr.id)}}"> <--- the msr.id is my ID
<button type="button">
<div class="font-weight-bold">Ajouter un commentaire</div>
</button>
</a>
这很好用,但我想知道是否有任何方法可以对表单执行相同的操作,因为我不是调用函数而是执行操作。这就是我的表单的外观:
<form id="commentaire_form" method="post" action="/testement"> <--- here is where I give the route but how can i send the ID to the function linked to this route?
<textarea id='text' name="text"></textarea>
<input type="submit">
</form>
如果有人可以帮助我,我将不胜感激,在此先感谢 :-)
【问题讨论】: