Fill in a field by selecting another field

0

I have an order form where the customer name is chosen and I would like the discount field to be filled in from this selection, this value is in the same table where the customer's registration is.

How can I make the discount field be populated from the customer's choice?

My select looks like this:

    $qr2=mysqli_query($conexao,"SELECT * FROM 'clientes' order by 'nome'");
if (mysqli_num_rows($qr2)==0)
    echo "Adicione ao menos um Cliente";

The field in the form where the client is chosen looks like this:

    <strong><b><font size="3"> <font color="#000000">Cliente :</strong>
<select name="clienteAt">  <option value="">Selecione o Cliente</option>
<?php
while ($row=mysqli_fetch_array($qr2)){
?>
<option value="<?php echo $row['id']?>"><?php echo $row['nome']?></option>
<?php }?>
</select>

and the discount field looks like this:

<td>
 <input name="desconto[]" type="text" required name="desconto"
  maxlength="30" size="11" onblur="Calc(this)"
  style="text-align:center"
  class="desconto" />
</td>
    
asked by anonymous 04.03.2018 / 16:52

1 answer

0

I'll try to sort of get the idea of what you can do.

1 - When selecting a client in your comboBox create an ajax request for another page ex: getconsole.php with the selected client id.

2- On the page getconsole.php get the id through a $ _GET and make your discount selection in your database.

3 - Give an ECHO discount on the same page.

4 - get the return of the ajax request made on the combobox page and fill in the input with that return.

I've come across the idea of what you can do.

    
04.03.2018 / 17:59