会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
a121984376
公告
日历
导航
博客园
首页
新随笔
新文章
联系
订阅
管理
JS取得RadioButtonList的Value,Text及选中值等信息
<
asp:RadioButtonList ID
=
"
RadioButtonList1
"
runat
=
"
server
"
RepeatColumns
=
"
4
"
RepeatDirection
=
"
horizontal
"
>
<
asp:ListItem Value
=
"
1
"
Text
=
"
A1
"
></
asp:ListItem
>
<
asp:ListItem Value
=
"
2
"
Text
=
"
A2
"
></
asp:ListItem
>
<
asp:ListItem Value
=
"
3
"
Text
=
"
A3
"
></
asp:ListItem
>
<
asp:ListItem Value
=
"
4
"
Text
=
"
A4
"
></
asp:ListItem
>
</
asp:RadioButtonList
>
<
input id
=
"
Button1
"
type
=
"
button
"
value
=
"
button
"
onclick
=
"
fn_GetRadioButtonListInfo();
"
/>
function
fn_GetRadioButtonListInfo()
{
//
取得RadioButtonList的集合
var
radListItems
=
document.all(
"
RadioButtonList1
"
);
if
(radListItems
==
null
)
{
alert(
"
相关对象对空
"
);
return
false
;
}
//
弹出RadioButtonList的Item的个数
var
radListItesCount
=
radListItems.length
-
1
;
alert(
"
Item个数
"
+
radListItesCount);
var
radListCheckedValue
=
""
;
//
遍历Item的Text和Value
for
(
var
i
=
1
; i
<=
radListItesCount ; i
++
)
{
var
itemInfo
=
""
;
itemInfo
+=
"
第
"
+
i
+
"
Item
"
;
//
Value
itemInfo
+=
"
Value:
"
+
radListItems[i].value;
//
Text
//
itemInfo += " Text: "+ radListItems[i].nextSibling.innerText ;
//
或者
itemInfo
+=
"
Text:
"
+
radListItems[i].parentElement.childNodes[
1
].innerText ;
//
是否是选中
itemInfo
+=
"
是否选中:
"
+
radListItems[i].checked;
//
if
(radListItems[i].checked)
radListCheckedValue
=
radListItems[i].value;
alert(itemInfo);
}
if
(radListCheckedValue
==
""
)
{
alert(
"
没有选中值
"
);
}
else
{
alert(
"
选中Value 为 :
"
+
radListCheckedValue);
}
return
false
;
}
posted on
2008-07-18 11:37
冰之玄岩,小小Programmer
阅读(
1417
) 评论(
0
)
编辑
收藏
举报
刷新页面
返回顶部
Copyright © 2025 冰之玄岩,小小Programmer
Powered by .NET 9.0 on Kubernetes