怎样同时提交两个表单?
我在做文件上传时,不仅要上传图片,还要上传文字,所以我用两个表单去处理,一个上传图片,一个上传文字,但有时候却只能一个表单提交,有时候两个都会提交这是怎么回事啊,还请高手帮忙,急!
<html>
<head>
<title>提交图片及产品说明资料</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td { font-size: 9pt}
a { color: #000000; text-decoration: none}
a:hover { text-decoration: underline}
.tx { height: 16px; width: 30px; border-color: black black #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; background-color: #eeeeee; color: #0000FF}
.bt { font-size:10pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 16px; width: 80px; background-color: #eeeeee; cursor: hand}
.tx1 { height: 20px; width: 30px; font-size: 9pt; border: 1px solid; border-color: black black #000000; color: #0000FF}
.style4 {font-size: 10pt}
.style5 {color: #FF0000}
-->
</style>
<script language="javascript">
function checkValue(){
//alert("***");
var fileName;
var filePath;
var start;
var end;
filePath=form1.file1.value;
//alert(filePath);
if(filePath!="") {
//alert("******");
start=filePath.lastIndexOf("\\")+1; //查找最后一位\字符下标
end=filePath.length;
fileName=filePath.substring(start,end);
form2.FileName.value=fileName;
}
if(form1.file1.value==""){
alert("请选择杂志的图片!");
form1.file1.setfocus();
return;
}
if(form2.ZaZhiId.value==""){
alert("请填写这是第几期的杂志!");
form2.ZaZhiId.setfocus();
return;
}
form1.submit();
form2.submit();
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="upload.asp" enctype="multipart/form-data" >
<table border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#CCCCCC" width="91" height="23">
<tr>
<td align="left" valign="middle" height="18" width="18"> </td>
<td bgcolor="#CCCCCC" align="left" valign="middle" height="18" width="67"> 提交资料</td>
</tr>
</table>
<br>
<input type="hidden" name="act" value="upload">
<br>
<table width="71%" border="1" cellspacing="0" cellpadding="5" align="center" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr bgcolor="#CCCCCC">
<td height="22" align="left" valign="middle" bgcolor="#CCCCCC"> √提交杂志图片及杂志说明资料</td>
</tr>
<tr align="center" valign="middle">
<td height="28" align="left" bgcolor="#EEEEEE" id="upid"> 杂志图片:
<input type="file" name="file1" ContentEditable="false" style="width:500" class="tx1" value=""></td>
</tr>
</table>
</form>
<form name="form2" method="post" action="upascii.asp" >
<table width="71%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolorlight="#000000" bordercolordark="#CCCCCC">
<tr align="center" valign="middle">
<td height="24" align="left" bgcolor="#eeeeee" ><div align="left" style="width:500"> 第几期杂志:
<input name="ZaZhiId" type="text" class="tx1" id="ZaZhiId" style="width:100; height:20" value="第一期" maxlength="50">
*格式一定要正确!</div></td>
</tr>
<tr align="center" valign="middle" bgcolor="#eeeeee">
<td height="24" align="left" bgcolor="#eeeeee" class="style4"><div align="center">
<input type="hidden" name="FileName" value="">
<input type="button" name="button1" value="[ 提交 ]" class="bt" onclick=checkValue() >
<input type="reset" name="reset" value="[ 重置 ]" class="bt" >
</div></td>
</tr>
</table>
</form>
</body>
</html>