capture value from another input with jQuery

Asked

Viewed 204 times

1

Guys I set up a system that when typing the user name in an input, jQuery captures the name and calls a php file. Which in turn makes a BD query and fills a select list.

Well the structure is 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 on jQuery has to be that of the input name

  • 1

    as it receives the $("#cliente").val() you do with $("#nome").val()

  • vlw thank you very much worked out ;)

1 answer

1


Just change the line

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

To

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

Don’t forget to set the type of your input client.

  • vlw thank you very much worked out ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.