![](/img/trans.png)
[英]Is there a way to pass the value from a button to a form when the user clicks submit?
[英]How to assign an arbitrary value to a variable when user clicks submit button?
當單擊提交按鈕時,可以將其name
和value
屬性與其余請求一起發送,以記住使用哪個提交按鈕發送表單數據。 但是,發送的值必須與按鈕上顯示的文本相同。 提交按鈕是否可以發送任意值而不是按鈕文本,最好是不依賴於啟用JavaScript的用戶? 此外,對於XHTML和HTML5,此問題的答案是否有所不同?
使用button
代替input
:
<button id="butter" type="submit" value="go">Let's do it</button>
示例: http : //jsfiddle.net/duySv/
這樣,標簽和值是分開的。
嘗試使用按鈕元素。
<form method="post">
<button name="abutton" value="abc">foo</button>
</form>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.