推 tayyih:感謝~~~ 06/25 00:31
※ 引述《tayyih (找回當初讀研究所的動力)》之銘言:
: 請問一個表單內是否可以有兩個或兩個以上轉向不同頁的送出按鈕呢?
: 例如按下上一頁鈕,就會送出表單並且跳回上一頁,
: 按下一頁鈕一樣會送出表單,但跳到下一頁,
: <form>裡面的action不是只能寫一個嗎?
: 就算可以寫兩個那要怎麼分辨是按了那個鈕呢?
: 我想了蠻久的,想不出來要怎麼做,
: 麻煩為我解答,謝謝。
網路上 google 一下就一堆了 ~
引用:
<SCRIPT language="JavaScript">
function OnSubmitForm()
{
if(document.pressed == 'Insert')
{
document.myform.action ="insert.html";
}
else
if(document.pressed == 'Update')
{
document.myform.action ="update.html";
}
return true;
}
</SCRIPT>
<FORM name="myform" onSubmit="return OnSubmitForm();">
<INPUT TYPE="SUBMIT" name="Operation" onClick="document.pressed=this.value"
VALUE="Insert">
<INPUT TYPE="SUBMIT" name="Operation" onClick="document.pressed=this.value"
VALUE="Update">
</FORM>
參考文章:http://www.javascript-coder.com/html-form/html-form-action.phtml
--
AppleBoy Blog: http://blog.wu-boy.com
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.107.202