Good morning, people,
I have in my home a field to consult CPF. The field has only a text field, where I inform the CPF, if I find any cpf in the database, it returns some data to me. I submit the form with ajax, not to reload the page, in the page that makes the query, I play the data in an array and convert it to json, I retrieve the value in my home and print them.
The div that showed the data, I leave it hidden: <style>style:display:none;</style>
When I press the button to search, it displays a table with the data:
<script>
$("#btnConsulta").click
(
function()
{
var show = $("#divForm").css("display","block");
}
);
</script>
Ai blz. But I would like the div with this table to be hidden again, after x seconds.
fix the code:
function hideDiv()
{
$("#divForm").css("display","none");
}
And I used setInterval to run it after x seconds. But if I define that I will call the hiding function in 10 seconds, if I enter the page, wait 5 seconds and search, my div will only be visible for 5 more.
I would like setInterval to start counting after I press the search button.
EDIT: ----------
Code that I use to submit the form and get the data.
<script type="text/javascript">
function consultaCpf()
{
jQuery(document).ready(function(){
jQuery('#form1').submit(
function(){
var dados = jQuery( this ).serialize();
jQuery.ajax
(
{
type: "POST",
url: "/admin2/inc/ajaxSubmit/consultaCpf.php",
data: dados,
dataType: "json",
success: function(json)
{
$('#nomeVendedor').html( json.vendedor);
$('#nomeCliente').html( json.cliente );
$('#cpfCliente').html( json.cpf );
}
}
);
return false;
});
});
}
consultaCpf();
</script>
Here he sends the form to the query pagePpf.php.
In the queryPpf.php page:
$return = array();
$cpf = $_POST['txtCpf'];
$sql = mysql_query("SELECT vendedor,nomeCliente,cpf
FROM tblVenda where cpf = '$cpf' ");
while($row = mysql_fetch_array($sql))
{
$vendedor = $row['vendedor'];
$cliente = $row['nomeCliente'];
$cpf2 = $row['cpf'];
}
$return['vendedor'] = $vendedor;
$return['cliente'] = $cliente;
$return['cpf'] = $cpf2;
echo json_encode($return);
Ha ha, grateful