好吧,所以我有一个脚本,当你点击一个链接它动态地添加一个表单字段是有可能的,所以当它被提交时,它会去“example.com?7”(7由于7档) 我的意思是,如果我点击5次,有5个文件字段和我选择5个文件,我可以让操作链接mysite.php 5使用javascript来改变提交链接
这里是脚本:
<!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=utf-8" />
<title>Untitled Document</title>
<script type="application/javascript">
function add(){
var field = document.createElement('input');
field.setAttribute("type", "file");
field.setAttribute("name", "yo");
document.getElementById('myform').appendChild(field);
}
</script>
</head>
<body>
<form id="myform" name="form1" enctype="multipart/form-data" method="post" action="">
<p>File:
<input type="file" name="hello" id="hello" />
</p>
<p>
<input name="submit" type="submit" value="Submit" />
</p>
</form>
<a href="#" onclick="add()">Click Here</a>
</body>
</html>
非常感谢!
工作就像一个魅力。非常感谢。 – DonJuma 2010-10-20 16:09:01