2
I have a page where it has an input that loads barcode data when opening an application on mobile.
When scanning the product barcode and loading the code into the input, I would like to have the page redirect to the search page of that scanned code without having to click the send button (Ubmit).
Today my page already works with the send button, but I have to scan the product through the camera of the phone and then press the send button, I wanted to automate this task by loading the code already made this send automatically. Follows the code:
<form action="consultar-item.php" method="POST">
<div class="form-group form-control-lg col-md-4">
<label for="cod">Busque o Codigo de Barras:</label>
(<a href="http://zxing.appspot.com/scan?ret=http://localhost:8084/appteste/index.php?codigo={CODE}">Leitor</a>):
<input type="text" class="form-control" name="cod" value="<?= $_GET['codigo'] ?>" />
</div>
<div class="clearfix"></div>
<div class="form-group form-control-lg col-md-3">
<label for="date1">Data Inicial da Pesquisa:</label>
<input type="date" class="form-control" name="date1" />
</div>
<div class="clearfix"></div>
<div class="form-group form-control-lg col-md-3">
<label for="date2">Data Final da Pesquisa:</label>
<input type="date" class="form-control" name="date2" />
</div>
<div class="clearfix"></div>
<div class="form-group form-control-lg col-md-2">
<input type="submit" class="btn btn-success" name="busca" id="butContato" value="ENVIAR"
</div>
</form>
Wouldn’t it be possible to do an if/Else with a setTimeout in and with a function that does Submit if the value received in the input is valid? Maybe you don’t even need the setTimeout... or you can do a setInterval to keep checking, and if it’s true you do the Submit. Here’s something that can help you https://www.formget.com/javascript-auto-submit-form/
– hugocsl
I’ll take a look and then I’ll answer, Thank you!
– Alex Sousa
At the event
onchange
input cannot do Ubmit via js?– Augusto Vasques