我有一个PHP文件,它有一个表单和2个提交按钮,onclick的1个按钮它必须通过从下拉列表中选择的值。它不会将值传递给接受POST数据的php文件。但是,如果我只有一个按钮和相同的形式,这工作正常。 我在下面找到我的代码。两个提交按钮和1个表单不传递值
<html>
<head>
<title>Invoice Printing</title>
<script type="text/javascript">
function showlink()
{
window.open('invoiceprint2.php');
}
function showlink3()
{
window.open('invoiceprint3.php');
}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#026465">
<tr>
<td><div align="center"><span class="style1"> Amogh Gases Private Ltd <br></span>
<center class="style5">INVOICE PRINTING</center>
<br><br>
<br>
</td>
</tr>
</table>
<!--------------VALIDATIONS ------------------->
<br>
<br>
<form name="form1" method="post" action="" target="_blank">
<table width='40%' height='39' border='0' cellpadding='2' cellspacing='0' align='center'>
<tr>
<td class='sty1'><div align='left'>Please select Invoice No. to PRINT: <br>
<br>
You can choose more than one invoice number from the options, by holding CTRL key on your keyboard and select the numbers.</div></td>
<td>
<?php
$con = mysql_connect("localhost","tech1","[email protected]#");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tech1", $con);
$result = mysql_query("SELECT Invno FROM INVHDR", $con);
echo "<select multiple='multiple' size='20' name='invnos[]'>";
while($nt=mysql_fetch_assoc($result))
{//Array or records stored in $nt
echo "<option value=$nt[Invno]>$nt[Invno]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
mysql_close($con);
?>
</td>
</tr>
</table><br>
<center><input name="PRINT" type="button" value="PRINT Invoice to Laser Printer!" onClick='showlink();' /> <input name="PRINT2" type="button" value="PRINT Invoice to Dotmatrix Printer !" onClick='showlink3();'/>
</form>
<br><br><br><br>
<a href='frameinvoice.php' target='_parent'><input name='Add' type='button' value='Add'></a> <a href='invoice-edit.php' target='_parent'> <input name='Edit' type='button' value='Edit !'></a> <a href='invoice-cancel.php' target='_parent'><input name='Edit' type='button' value='Cancel !'></a> <a href='index.htm' target='_parent'><input name='Close' type='button' value='CLOSE !'></a><br></center>
</center>
</body>
</html>
您的 “提交” 按钮打印和PRINT2? – Mate
@mate是的,是否应该更改名称以提交两个按钮? – user1114409
@Mate我试图改变按钮名称提交,它不起作用 – user1114409