Select 具有输入启用属性的标签

Select tag that has input enable attribute

我有一个页面,用户可以提交 news.the 用户能够从下拉列表中 select news group,如您在此处所见:

   <select class="form-control" name="NewsGroup" id="NewsGroup">

                                    @foreach (string Group in ViewBag.NewsGroup)
                                    {
                                        <option value="@Group">@Group</option>
                                    }
                                </select>

问题是,如果下拉列表中不存在组,用户应该可以输入新组。但是 select 标签没有任何用户可以输入的选项新值和用户必须从列表中 select。 如何将此选项添加到 drop down list?

您不能为此目的只使用一个 select。

一种解决方案是添加一个名为 "other" 的选项,然后在下面添加一个输入文本,用户可以在其中输入他想要的内容。选择性,您只能在选项"other"为select ed时显示文本输入。