- 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>
.
推薦閱讀
- Learn TypeScript 3 by Building Web Applications
- C語言程序設(shè)計習題解析與上機指導(第4版)
- MATLAB圖像處理超級學習手冊
- 實戰(zhàn)Java程序設(shè)計
- Java開發(fā)入行真功夫
- 零基礎(chǔ)學Java程序設(shè)計
- Python:Master the Art of Design Patterns
- 程序員修煉之道:通向務實的最高境界(第2版)
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- Statistical Application Development with R and Python(Second Edition)
- Red Hat Enterprise Linux Troubleshooting Guide
- Python數(shù)據(jù)科學實踐指南
- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)
- Magento 2 Developer's Guide
- Mastering Machine Learning with scikit-learn