怎么样才能获取,页面多个listbox ,其中以个LISTBOX的值?

来源:百度知道 编辑:UC知道 时间:2024/06/23 12:37:09
页面有多个LISTBOX,我点击编辑按纽的时候,获取当前选中的LISTBOX的值

<div>
<asp:ListBox ID="lb1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:ListBox>
<asp:ListBox ID="lb2" runat="server">
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:ListBox>

<input type=button onclick="check()" />
</div>
<script language="javascript" >
function check()
{
var obs = document.getElementsByTagName('select');
for(var i = 0; i<obs.length;i++)
{
//alert(obs[i].selectedIndex);
if(obs[i].selectedIndex != -1)
{
alert(obs[i].options[obs[i].selectedInde