如何在HTML / Javascript中创建可编辑的组合框? [英] How can I create an editable combo box in HTML/Javascript?

查看:788
本文介绍了如何在HTML / Javascript中创建可编辑的组合框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让用户从下拉列表中选择一个项目,但也允许他们输入任何文本,即使它与列表中的项目不匹配。如何在具有HTML和Javascript的网页上实现此功能?

I need to let users select an item from a dropdown list, but also allow them to instead enter any text, even if it doesn't match an item in the list. How can I achieve this on a web page with HTML and Javascript?

选择字段不允许用户输入文本,输入文本字段未显示首选备选项。

The select field doesn't let users enter text, and the input text field doesn't show the preferred alternatives.

推荐答案

这里是一个简单的自动完成脚本:
演示
来源

Here is a script for that: Demo, Source

或其他一个工作略有不同:
链接已删除(网站已不存在)

Or another one which works slightly differently: link removed (site no longer exists)

这篇关于如何在HTML / Javascript中创建可编辑的组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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