木子屋 Dnawo's BLOG

动态改变表单action的值

👤 dnawo 📅 2006-10-19 👁 5256 👍 0 💬 0 🔄 本站原创
有时根据实际需要会设置不同的按钮,当点击不同的按钮时将同一表单发送到不同的页面中进行处理,这就需要动态的改变表单action的值,实现方法如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function fun1(){
document.form1.action="asp1.asp";
document.form1.submit();
return true;
}
function fun2(){
document.form1.action="asp2.asp";
document.form1.submit();
return true;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="button" name="Submit" onclick="fun1();" value="收藏" />
<input type="button" name="Submit2" onclick="fun2();" value="提交" />
</form>
</body>
</html>

评论(0)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 从电影《防火墙》看黑客的社会工程学 下一篇 → javascript在href和在onclick中的区别