Automatic form search using data from a string

0

I have a string $numero and it returns several numbers.

I also have a start page (index.php) with a form like this:

<html>
<body>
<div width="100%" height="100%" align="center">

 <!-- htaccess tratando o pagina/ para pagina.php -->

  <form name="formulario" id="formulario" method="post" action="pagina/">


    <input type="text" name="numero" id="numero">
    <input type="hidden" name="inicial" id="inicial" value="S">
    <input type="hidden" name="ws" id="ws">
    <input type="button" value="Consultar" onclick="formulario.ws.value=0; submit()" />
    <input type="button" value="Consultar + webservice" onclick="formulario.ws.value=1; submit()" />
     </form>
    </div>
   </body>
 </html>

The home page has two buttons. In addition, there is a page (page.php) that treats the search, saves in the database the search among others.

When I enter the index.php and fill in the number and click on the second button2 (Query + webservice) it returns what I need on the page.php.

How do I do automatic searches with a time space of X using my string $numero ?

That is, I want to optimize the time and not have to do search by searching the form of index.php, ie I want something automatic (with time space X) that uses the $ number and go do the searches and saving in the database.

    
asked by anonymous 22.06.2017 / 15:43

1 answer

0

This would be an example to check if the number is filled, if it does, it simulates the click on your button that queries the WebService. The check is in 60 seconds, if you want to change it to 4 seconds for example, change the 60000 to 4000.

setInterval( function(){
    var valueNumero = $('#numero').val().trim();

    if(!!valueNumero)
    {
        // Ação no primeiro botão
        // $('button[value="Consultar"]', '#formulario').click();

        // Ação no segundo botão
        $('button[value="Consultar + webservice"]', '#formulario').click();
    }

}, 60000);
    
23.06.2017 / 16:21