html:optionsCollection和html:options的区别

html-css08

html:optionsCollection和html:options的区别,第1张

<html:optionsCollection>:

<html:select>:标签中可以嵌套多个<html:optionsCollection>标签标签与<html:options>标签相似,他通过name属性或property属性指定一个集合对象,该对象中的每一个元素为一个Bean,并且在Bean中分别具有与标签中label属性和value属性指定的值匹配的getXXX方法。

<html:option>:

标签生成HTML<option>元素,这个标签被嵌套在<html:select>标签中,代表列表的一个可选项的Label,既现在是在页面上的值。这中值有两个来源。

1.直接指定文本内容

<html:option value="1">Label来源1:直接指定文本内容</html:option>

2.通过Resource Bundle中的内容。

<style>

select

{

background-color:#ad3db1

color:#000000

width:150px

}

</style>

<select name=selzd onchange=text() align=center>

<option>--选择支付类型--</option>

<option>--直接支付--</option>

<option>--保证金支付--</option>

</select>

<br>

<select name=selfd align=center>

</select>

<script>

var zj_pay=new Array("支付成功","支付中","支付失败")

var bzj_pay=new Array("保证金冻结","发出货物","验货确认","支付货款","支付中","支付失败","订单关闭")

function text()

{

selfd.options.length=0

if(selzd.selectedIndex==1)

{

var l=zj_pay.length

for(i=0i<li++)

{

x=document.createElement("<option>")

x.innerHTML=zj_pay

selfd.insertBefore(x)

}

}

if(selzd.selectedIndex==2)

{

var l=bzj_pay.length

for(i=0i<li++)

{

x=document.createElement("<option>")

x.innerHTML=bzj_pay

selfd.insertBefore(x)

}

}

}

</script>哈哈 刚好写过这么个东西用js写的 应该能满足你的要求很容易改的 不懂得还可以问我给分吧 HOHO

<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>