我有一個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