Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML form with 2 (hidden) submit buttons and 1 other hidden input
    primarykey
    data
    text
    <p>I'm trying to build this application that runs on Android tablets with barcode scanners attached. The barcode scanners send an Enter after each scanned code.</p> <p>I need to scan 2 barcodes and submit the form.</p> <p>I created a form with two sets of input + submit button, the second one hidden. After the first barcode is scanned and the scnner send the Enter key, the hidden elements are revealed and I can scan the second barcode. However, the second time the Enter key doesn't work. It only work if I push the button (after I unhide it). How can I take care of this so it will not need user input (other than scanning barcodes)?</p> <p>Here's my code so far:</p> <pre><code> &lt;form action="barcode.php" method="post" class="pure-form" style="width:100%"&gt; &lt;fieldset&gt; &lt;legend&gt;Scaneaza o fisa noua de &lt;?php echo $operation; ?&gt;:&lt;/legend&gt; &lt;input type="text" name="barcode" autofocus id="InputID" placeholder="Codul de bare" style="width:100%;font-size:2em"&gt; &lt;button style="width:0;visibility:hidden;" type="submit" onclick="show_popup('my_popup'); return false;"&gt;&lt;/button&gt; &lt;div id="my_popup" style="display:none;border:3px dotted gray;padding:.3em;background-color:white;position:absolute;width:80%;height:20%;margin:-50px 50px 0 50px;"&gt; &lt;legend&gt;Introdu numarul de KO-uri:&lt;/legend&gt; &lt;input type="text" name="kos" autofocus id="InputID" placeholder="KO-uri" style="width:100%;font-size:2em"&gt; &lt;button type="submit" class="pure-button pure-button-primary" style="/*width:0;visibility:hidden;*/" onclick="hide_popup('my_popup'); return true;"&gt;Trimite&lt;/button&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; function FocusOnInput() { document.getElementById("InputID").focus(); } function show_popup(id) { if (document.getElementById){ obj = document.getElementById(id); if (obj.style.display == "none") { obj.style.display = ""; } } } function hide_popup(id){ if (document.getElementById){ obj = document.getElementById(id); if (obj.style.display == ""){ obj.style.display = "none"; } } } &lt;/script&gt; </code></pre> <p>And the barcode.php file:</p> <pre><code> &lt;?php ob_start(); mysql_connect ("localhost","root","root") or die (mysql_error()); mysql_select_db ("eficacitate"); $barcode = $_POST["barcode"]; $kos = $_POST["kos"]; $marca = $_COOKIE["marca"]; $operation = $_COOKIE["operation"]; if (substr($barcode,0,1)=="^") { $j_nou = substr($barcode,1,strpos($barcode, "|")-1); $parts = explode('|',$barcode); $of_nou = $parts[1]; $cantitate_nou = $parts[2]; $serie_nou = $parts[3]; $adauga="INSERT INTO master (marca, operation,j,of,cantitate,serie,kos) VALUES ('$marca','$operation','$j_nou','$of_nou','$cantitate_nou','$serie_nou','$kos')"; mysql_query($adauga); } header('Location: /eficacitate/scan.php'); ob_flush(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload