我正在构建一个 Web 应用程序,它会返回一份报告。对于用户请求下拉列表的某些参数,他们还希望能够一次选择多个选项。
例如,向我展示来自 TX、WV 和 ID 状态的所有交易。
我决定使用他们请求的下拉列表而不是列表框的原因是他们可以从中选择 40 多个参数,而且我的页面已经塞满了这么多控件。
先谢谢了。
我正在构建一个 Web 应用程序,它会返回一份报告。对于用户请求下拉列表的某些参数,他们还希望能够一次选择多个选项。
例如,向我展示来自 TX、WV 和 ID 状态的所有交易。
我决定使用他们请求的下拉列表而不是列表框的原因是他们可以从中选择 40 多个参数,而且我的页面已经塞满了这么多控件。
先谢谢了。
You won't be able to do it with a dropdownlist directly but what you could do is fake it.
Have a hidden ListBox on your page. Construct something that looks like a dropdownlist visually (label + image would work). During the onclick event of your fake dropdownlist show your listbox underneath your dropdownlist. Hide the listbox during the onblur event for the ListBox. Also you could throw in some jquery to animate the unveiling of your listbox to more closely match the look of a dropdownlist.
试试这个:有一个未选中选项的下拉列表和一个选中的列表框;类似于 anton lavey 的建议,但稍微不那么详细。
<style>
select { width: 200px; }
</style>
<body>
<select id="sel" onchange="list.appendChild(this[this.selectedIndex]);">
<option disabled>Select items from this list</option>
<option value="a">a</option>
<option value="c">c</option>
<option value="d">d</option>
</select><br>
<select multiple="" id="list"><option value="b">b</option></select>
<button onclick="while(list.selectedIndex > -1) { sel.appendChild(list[list.selectedIndex]); }">Remove selected</button>
</body>
如果您扫描以找到正确的插入位置,则可以保留排序。