capture value of another input with jQuery

1

Galera I put up a system that when entering the user name in an input, jQuery captures the name and calls a php file. Which in turn makes a query in the DB and populates a select list.

Well, the structure looks like this:

function buscar_f_pagamento() {
  var id = $('#cliente').val();
  if (id) {
    var url = 'Busca/Casas.php?id=' + id;
    $.get(url, function(dataReturn) {
      $('#load_f_pagamento').html(dataReturn);
    });
  }
}
<input type='text' id='nome' name="nome" value='1'>

<input name="cliente" id="cliente" onchange="buscar_f_pagamento()">




<select name='casa' id="load_f_pagamento"></select>

Well what I need to do is when I call the buscar_f_pagamento in the input cliente the value that has to be passed in jQuery must be the input name

    
asked by anonymous 18.10.2016 / 13:29

1 answer

1

Just change the line

var id = $('#cliente').val();

To

var id = $('#nome').val();
  

Do not forget to set the type of your client input.

    
18.10.2016 / 13:33