HTML输入自动完成/建议 [英] HTML input autocomplete/suggestion

查看:142
本文介绍了HTML输入自动完成/建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何进行输入,以便用户单击时显示输入可以使用的所有可能值?我可以使用php从数据库中获取值,但是要显示如下图所示的图像,我想我必须使用javascript?我该怎么办?

How can make an input so that when the user click on it, it display all the possible values that the input can take? I can get the values from my database using php, but to display something like the image below, I guess I will have to use javascript? How can I do it?

例如,在phpPgAdmin中:

For example, in phpPgAdmin:

推荐答案

HTML中的select标记如何?它会创建一个下拉菜单,其中包含可从php脚本(从数据库获取)中加载的选项. W3Schools的一个示例在这里:

How about the select tag in HTML? It creates a drop-down menu with options that you can load from your php script (which fetches from the database). An example from W3Schools is here:

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

这篇关于HTML输入自动完成/建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆