【问题标题】:How can autofill another text box as I type in the first textbox in jquery and ajax当我在 jquery 和 ajax 中输入第一个文本框时,如何自动填充另一个文本框
【发布时间】:2023-03-21 01:13:01
【问题描述】:

如何在另一个文本框中从 jquery + ajax 生成结果

<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>

编辑: 我编辑了一些内容..很抱歉忘记提到我将使用#data文本框在数据库中查询它,我将在#response文本框中显示结果,请原谅我当时很困惑

任何建议家伙?这可能吗?任何帮助表示赞赏。谢谢

【问题讨论】:

  • 对不起我的问题,我更新了,忘了说我需要使用#data在数据库中查询它,我想要实现的表格就像一个自动完成的表格,对不起我的语法也是。

标签: javascript input autofill


【解决方案1】:

这一定能解决问题:

您的表格:

<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());
  });
});

【讨论】:

  • 对不起我的问题,我更新了,忘了说我需要使用#data在数据库中查询它,我想要实现的表格就像一个自动完成的表格,对不起我的语法也是。
猜你喜欢
  • 2014-12-13
  • 2011-03-14
  • 1970-01-01
  • 1970-01-01
  • 2017-07-23
  • 2012-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多