1

I want to send a hidden data and user input data to another page. First, I tried making only one user input, then the system could send the data as I wanted.

<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>

With above code, I can send the user and the hidden data. But, when I add a new line for user input, it can't send the data.

<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>

I do not create a submit button because we want to use bar code scanner. I don't think submit button is the problem because when I create only one user input, the system can run without a submit button.

Whit Waldo
  • 4,806
  • 4
  • 48
  • 70
GagakAngkasa
  • 39
  • 1
  • 9

1 Answers1

1

Instead of closing the form tag immediately try to wrap the inputs in the form tags like so

<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>
Ruben Funai
  • 629
  • 5
  • 5
  • thanks @Ruben Funai. I was tried your suggestion. it still can't send the data.. when i click "Enter" nothing happen. – GagakAngkasa Apr 15 '16 at 03:47
  • 1
    Because you now have 2 input fields you need a submit button to trigger the submission. Add another row to your table with a hidden button should do the trick. Something like `` – Ruben Funai Apr 15 '16 at 03:55
  • 1
    You can see this post about the little "quirk" http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input – Ruben Funai Apr 15 '16 at 03:57