2016-04-15 87 views
1

我想发送一个隐藏的数据和用户输入数据到另一个页面。首先,我试着只做一个用户输入,然后系统可以按照我的意愿发送数据。不能发送数据到另一页

<h1><strong>Please scan barcode on JIG</strong></h1> 
<table> 
<form action="productjit21.php" method="post" name="check2"/> 
<input type="hidden" name="productnumber" value="<?php echo $productnumber; ?>"> 
<tr><td>JIG Barcode</td><td>:</td><td><input type="text" name="jitcode2" maxlength="50"/></td></tr> 
</table> 

通过上面的代码,我可以发送用户和隐藏数据。但是,当我为用户输入添加新行时,它不能发送数据。

<h1><strong>Please scan barcode on JIG</strong></h1> 
<table> 
<form action="productjit21.php" method="post" name="check2"/> 
<input type="hidden" name="productnumber" value="<?php echo $productnumber; ?>"> 
<tr><td>JIG Barcode</td><td>:</td><td><input type="text" name="jitcode1" maxlength="50"/></td></tr> 
<tr><td>JIG Barcode</td><td>:</td><td><input type="text" name="jitcode2" maxlength="50"/></td></tr> 
</table> 

我没有创建提交按钮,因为我们想使用条形码扫描器。我不认为提交按钮是问题,因为当我只创建一个用户输入时,系统可以在没有提交按钮的情况下运行。

回答

1

,而不是关闭表单标签立即尝试来包装投入的形式标记,以便

<form action="productjit21.php" method="post" name="check2"> 
<input type="hidden" name="productnumber" value="<?php echo $productnumber; ?>"> 
<tr><td>JIG Barcode</td><td>:</td><td><input type="text" name="jitcode1" maxlength="50"/></td></tr> 
<tr><td>JIG Barcode</td><td>:</td><td><input type="text" name="jitcode2" maxlength="50"/></td></tr> 
</form> 
+0

感谢@Ruben船井电机等组成。 我试过了你的建议。它仍然无法发送数据..当我点击“Enter”时什么也没有发生。 –

+1

因为您现在有2个输入字段,您需要一个提交按钮来触发提交。用隐藏的按钮添加另一行到你的表应该做的伎俩。就像'' –

+1

你可以看到这篇关于“quirk”的文章http://stackoverflow.com/questions/1370021/why-does-forms-with-single -input-field-submit-upon-press-enter-key-in-input –