-2
Good guys I have a form that saves the data in the database and works fine , but I need to click submit the form appear a div
hidden with the list of data saved in the database (I already have the right list) my big problem and the div
appear as soon as you submit the form without updating the page , I tried some codes in Javascript and jQuery that did not work. Can someone help me ?
This and the form to enter the data :
<form action="" method="post" id="meufrm" enctype="multipart/form-data">
<fieldset>
<legend style="color: #ffffff" class="btn btn-inverse">Cadastro </legend>
<label for="nome" style="color: #000"><strong>Nº da Venda :</strong> </label>
<input type="number" name="num_venda"></br></br>
<div id="datavenda">
<label for="nome" style="color: #000"><strong>Data :</strong> </label>
<input type="date" name="data_venda"></br></br>
</div>
<div id="placavenda">
<label for="nome1" style="color: #000"><strong>Placa :</strong> </label>
<input type="text" name="placa" ></br></br>
</div>
<div id="kmvenda">
<label for="imagem" style="color: #000"><strong>KM : </strong></label>
<input type="number" name="km"></br></br>
</div>
<?php
mysql_connect('127.0.0.1','root','');
//escolher a base de dados
mysql_select_db('mecanica');
$query='Select * from produtos';
?>
<label for="produtos" style="color: #000"><strong>Produto : </strong></label>
<select name="produtos">
<?php
$resultado=mysql_query($query);
while($linha=mysql_fetch_array($resultado))
{
echo '<option value="' . $linha['id_produto'] . '">' . $linha['produtos'] . '</option>';
}
echo '</select>';
?>
</select><br><br>
<div id="servicovenda">
<?php
mysql_connect('127.0.0.1','root','');
mysql_select_db('mecanica');
$query='Select * from servicos';
?>
<label for="servicos" style="color: #000"><strong>Serviços : </strong></label>
<select name="servicos">
<?php
$resultado=mysql_query($query);
while($linha=mysql_fetch_array($resultado))
{
echo '<option value="' . $linha['id_servico'] . '">' . $linha['servicos'] . '</option>';
}
echo '</select>';
?>
</select><br><br>
</div>
<div id="enviarvenda">
<input type="submit" class="btn btn-inverse" value="Enviar" name="send" >
<a href="listadevendas.php" class="btn btn-inverse" >Cancelar</a>
</div>
</fieldset>
and as soon as I sent the data I would have q list the results of the hidden div on the same page
Post the code as far as you’re ready for us to help you.
– Ivan Ferrer
I recommend you read this question: Why should we not use mysql type functions_*?
– Ivan Ferrer
The way to do what you want, is through ajax request, using Javascript: JSON object control, DOM manipulation. I recommend that you study a little more on the subject, before picking up code at random. The jQuery library has some facilities in this sense.
– Ivan Ferrer
I’ll give a study on jQuery then , obg.
– Matheus Goes