简体   繁体   中英

How can autofill another text box as I type in the first textbox in jquery and ajax

How can I generate a result from jquery + ajax in a another text box

<form action="someanotherpage.php">
   <input type="text" name="data" value="" id="data"/>
   <input type="text" name="response_data_here" value="" id="response"/>
    <input type="submit" value="Apply" />
</form>

EDIT: I edited some content..Im so sorry forgot to mention that I will use the #data textbox to query it in a database and I will display the result in the #response textbox ,forgive me I was confused at the moment

any suggestion guys?is that possible?any help is appreciated. thanks

This must do the trick:

Your Form:

<form action="someanotherpage.php">
   <input type="text" name="data" value="" id="data "/>
   <input type="text" name="response_data_here" value="" id="data2" />
</form>

JQuery:

$(function(){
  $("#data").keypress(function(){
    $("#data2").val($(this).val());
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM