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

查看:14
本文介绍了如何在 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?

select 字段不允许用户输入文本,input 文本字段不显示首选选项.

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

如果用户打开下拉菜单,所有项目都必须显示,因此它不能是仅显示匹配项目的简单自动完成.

All items must show if the user opens the dropdown, so it can't be a simple auto-complete that only shows matching items.

推荐答案

这是一个脚本:演示来源

或另一种工作方式略有不同的:链接已删除(站点不再存在)

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

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

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