Pass an "id" value to an input field

0

I use the following function:

public function autoCompleteCilindro($q){

    $this->db->select('*');
    $this->db->limit(5);
    $this->db->like('passo', $q);
    $query = $this->db->get('cilindros');
    if($query->num_rows() > 0){
        foreach ($query->result_array() as $row){
            $row_set[] = array('label'=>'Impressora: '.$row['impressora'].'    |    Cilindro: '.$row['engrenagens'].'    |    Passo: '.$row['passo'].'    |    Quantidade: '.$row['quantidade'],'quantidade'=>$row['quantidade'],'id'=>$row['idCilindro'],'engrenagens'=>$row['engrenagens']);
        }
        echo json_encode($row_set);
    }
}

I type the approximate value of a step, 200 for example and the table fields "cylinders" are shown to me.

This I do in an input field.

I need to have the result of dividing the field "step" divided by the field "quantity" into the "height" field.

                                    <div class="span6" style="margin-left: 0">
                                        <label for="impressora">Impressora  |  Engrenagem  |  Passo  |  Quantidade de Cilindros<span class="required"></span></label>
                                        <input name="impressora" id="impressora" class="span12" type="text" value="" />
                                    </div>


                                    <div class="span3">
                                        <label for="altura">Altura</label>
                                        <input name="altura"  id="altura" readonly class="span12" type="text" value="" />

                                    </div>

                                    <div class="span3">
                                        <label for="quantidade">Quantidade</label>
                                        <input name="quantidade" id="quantidade" class="span12" type="text"  value="" />
                                    </div>
    
asked by anonymous 05.08.2018 / 05:38

2 answers

0

If I did not get it wrong, it would be this way.

See the example: link

    
06.08.2018 / 15:16
-1

function pesquisa(){
		var valorInput = document.getElementById('procura').value;
		$.post('/valida.php',{valor: valorInput},function(data){
			 document.getElementById('resultado').innerHTML = data;
		})
	}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script><form><inputtype="text" id="procura" onkeyup="pesquisa();">
	<button>Pesquisar</button>
</form>
<div id="resultado"></div>
    
05.08.2018 / 18:43