I have a Payments table, which has 3 fields (id, item, amount) with the following query, with which I fill a combobox with all items, now I want to make that every time I select an item, the amount is automatically filled in an imput that I have in the form.
<div class="form-group">
<label class="col-sm-2 control-label" for="Old">Tipo de pago* </label>
<div class="col-sm-10">
<select class="form-control" id="pagos" name="pagos" >
<option value="" >Selecciona pago</option>
<?php
$sql = "select id, rubro, monto from pagos";
$q = $conn->query($sql);
while($r = $q->fetch_assoc())
{
echo '<option value="'.$r['id'].'" '.(($pagos==$r['id'])?'selected="selected"':'').'>'.$r['rubro'].'</option>';
}
?>
</select>
</div>
</div>