我在HTML表單中有2個提交按鈕。帶有多個提交按鈕的html表單
如何知道哪個提交按鈕觸發了JavaScript功能?
<script language="javascript" type="text/javascript">
function verifyData(formdata) {
// Here I want to know from which submit button this function is triggered
// I can't use type button instead of submit
// I can't use onclick handler
// I can't use JQuery.. I want to do only with javascript
}
</script>
<form onsubmit="verifyData(this);" method="post">
<input type="submit" value="submit1">
<input type="submit" value="submit2">
</form>
<button value="delete row" id="but1" onclick="disps()">delete row</button>
我想根據點擊不同的提交按鈕做不同的操作。
你想要執行什麼不同的操作?你可以簡單地檢查服務器上的值,如果你給輸入相同的名稱 – Alex