在同一form表單中如何提交兩個(gè)不同的action
有兩種辦法可以實(shí)現(xiàn):
1.針對(duì)一個(gè)action有多個(gè)提交按鈕,那么在提交后進(jìn)行根據(jù)ID進(jìn)行一下判斷,是哪個(gè)提交的執(zhí)行哪種動(dòng)作,這是可以實(shí)現(xiàn)的。
2.直接做成兩個(gè)form,每個(gè)form里的action不同,都有一個(gè)提交按鈕,從客戶看來(lái)是沒(méi)有區(qū)別的,但是提交的時(shí)候,會(huì)提交到不到的action里去.
第一種的實(shí)現(xiàn):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Java Applet......</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="pragma" content="no-cache">
<meta name="Author" content="YuLimin,俞黎敏,DayBreak,Beyond DayBreak Office Master">
</head>
<body bgcolor="#FFFFFF">
<center>
<form action="" name="form1">
<input type="button" value="查詢1" type="submit" onclick="form1.action='action_1';form1.submit();"/>
<input type="button" value="查詢2" type="submit" onclick="form1.action='action_2';form1.submit();" />
</form>
</center>
</body>
</html>
例子:這樣也許更清晰:
<Script Language="JavaScript">
function modify()
{
document.form1.action="modify.jsp";
document.form1.submit();
}
function delete()
{
document.form1.action="delete.jsp";
document.form1.submit();
}
</Script>
<form name="form1" action="">
<INPUT Type="Button" Name="Modify" Value="修 改 " onClick="modify()">
<INPUT Type="Button" Name="Delete" Value="刪 除 " onClick="delete()">
</form>
這樣可以實(shí)現(xiàn)將多個(gè)按鈕發(fā)送到不同網(wǎng)頁(yè)中。
第二種實(shí)現(xiàn):
提交form的時(shí)候,里面的action不能帶參數(shù)。
如:
<form action="test.do?args=888">
<input type="button" value="submit">
</form>
通過(guò)這個(gè)方法,test.do無(wú)法讀取args,必須換成一下寫法
<form action="test.do">
<input type="hidden" name="args" value="888">
<input type="button" value="submit">
</form>
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。