Is it possible to show all options from an HTML Select form field at once without clicking it?

六月ゝ 毕业季﹏ 提交于 2020-02-18 11:04:50

问题


I am using the X-Editable jQuery edit in place library for a Task Status selection field. All it;s stages are shown below from the process of:

  1. Clicking the Status
  2. It then hides the status SPAN and reveals the hidden Selection field.
  3. You can click the selection field which makes it dropdown and show all available options.
  4. Clicking a new Selection option value then shows a loading spinner image while it makes an AJAX request to save the value
  5. It then Shows the new selected Status Value SPAN.
  6. Clicking again restarts the cycle/process.


I am however trying to come up with a better way to select a new value. There are only 3 selection options so I would like to possibly show all 3 items at once instead of requiring you to click the dropdown to see the other 2 options.

Is it possible to do that with a basic Selection or does it require a Multi-select field?


回答1:


http://jsfiddle.net/n1k5cLx0/

Are you looking for a list or do you still want a dropdown with the options shown as default. For a list style you could use the size attribute with the select element.

HTML

<select size="3">
  <option>Not Started</option>
  <option selected>In Progess</option>
  <option>Completed</option>
</select>

CSS

select{
    overflow:auto;
}



回答2:


$("#Id_Selecteventtype")[0].selectedIndex = 1;



来源:https://stackoverflow.com/questions/31010787/is-it-possible-to-show-all-options-from-an-html-select-form-field-at-once-withou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!