需要准备的材料分别有:电脑、浏览器、html编辑器。
1、首先,打开html编辑器,新建html文件,例如:index.html,编写问题基础代码。
2、在index.html中的<script>标签,输入js代码:style="color: blueviolet"。
3、浏览器运行index.html页面,此时option标签的颜色被成功修改了。
<html:optionsCollection>可直接放集合例如有一个集合对象为List<Student>
studentList
而这个Student类又有属性name和Id
那么想直接在下拉列表框里显示集合里的所有成员
<html:select>
<html:optionsCollection
name="studentList"
lable="列表显示的比如name"
value="id">
</html:select>
这样就把这个集合显示在下拉列表框里了
-------------------
html:optionsCollection标签
html:optionsCollection标签生成多个HTML的option元素。
<html:select
name="selectForm"
property="person.id"
size="1">
<html:optionsCollection
name="selectForm"
property="persons"
label="name"
value="id"/>
</html:select>
html:optionsCollection标签就是一个可以很容易就实现动态下拉列表实现的一个标签
--------------------------------------------------------------------------------
html:options标签
html:options标签生成多个HTML的option元素。
<bean:define
id="personCollection"
name="selectForm"
property="persons"/>
<html:select
name="selectForm"
property="person.id"
size="1">
<html:options
collection="personCollection"
property="id"
labelProperty="name"/>
</html:select>
<html:select
name="selectForm"
property="person.id"
size="1">
<html:options
property="ids"
labelProperty="names"/>
</html:select>
html:options标签的作用和html:optionsCollection标签的作用基本一样,只是用法上稍有出入
<select name="Select1" onchange="slt()"><option value="1">第一项</option>
<option selected value="2">第二项(默认选中)</option>
<option value="3">第三项</option>
<option value="4">第四项</option>
</select>
<script>
function slt()
{
var obj=document.getElementById("Select1")
alert(obj[obj.selectedIndex].innerText)//这里就是取值
}
</script>