我一直在努力實作一些東西,以便當我收到POST 時,我知道哪個表單發送了它
我檢查了表單屬性,它似乎沒有ID或類似的東西,我想不出其中有什么功能,我想出的一router.post()點點沒有用
這是表格
<form action="/dashboard/" method="POST">
<div class="form-group">
<button class="btn btn-success">Do!</button>
</div>
</form>
我想知道發送帖子的表格是否是那個表格。
這是我收到的方式POST在其各自的。js檔案
router.post("/", async (req, res) => { . . .
我試過用 測驗一些東西req,但沒有任何運氣
作為一些相關資訊,我使用的是 Bootstrap 5,我沒有自己的樣式或類。
uj5u.com熱心網友回復:
向表單添加一個隱藏的輸入欄位,如
<input type="hidden" id="formName" name="formName" value="myDashboardForm">
然后訪問后端的 POST 變數中的“formName”。
uj5u.com熱心網友回復:
一個簡單的方法是包含一個隱藏的輸入
<form action="/dashboard/" method="POST">
<div class="form-group">
<button class="btn btn-success">Do!</button>
</div>
<input type="hidden" id="formId" name="formId" value="formType1">
</form>
然后你應該能夠得到 formType req.body.formId
uj5u.com熱心網友回復:
使用表單ID添加要隱藏和訪問的輸入欄位
<form action="/dashboard/" method="POST">
<div class="form-group">
<button class="btn btn-success">Do!</button>
</div>
<input type="hidden" id="formId" name="formId" value="formType1">
</form>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/398165.html
標籤:javascript html 节点.js 把手.js 快速车把
