- Practical Web Development
- Paul Wellens
- 132字
- 2021-07-16 13:14:08
Drop-down lists
Often we need to have visitors make a choice from a list. For this purpose, we can use the <select>
element in combination with the <option>
tag for every inpidual choice. The text portion of the <option>
element is what will be displayed, and the value of the value
attribute is what will be passed on for processing. It is very useful to make the first option the one that is not to be chosen, as in the following example:
<select name="colorlist" id="colorlist"> <option value="0">Choose a color</option> <option value="red">Red</option> <option value="blue">Blue</option> <option value="green">Green</option> <option disabled value="orange">Orange</option> </select>
The disabled attribute
Both the <select>
and the <option>
support disabled in case you want to enable an option (or the entire drop-down list) to be displayed but not selectable.
The selected attribute
If you want to preselect one of the choices, use the selected attribute of <option>
.
推薦閱讀
- Learning Python Web Penetration Testing
- Computer Vision for the Web
- 新一代通用視頻編碼H.266/VVC:原理、標準與實現
- 深入淺出Java虛擬機:JVM原理與實戰
- Magento 2 Theme Design(Second Edition)
- Mastering Spring MVC 4
- Mastering Kotlin
- Django:Web Development with Python
- Python數據可視化之Matplotlib與Pyecharts實戰
- C語言程序設計
- Spring Boot企業級項目開發實戰
- 深入RabbitMQ
- Mastering JavaScript Design Patterns(Second Edition)
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- Drupal 8 Development Cookbook(Second Edition)