zoukankan
html css js c++ java
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
;
}
查看全文
相关阅读:
inotify事件监控
NFS网络文件共享服务
Rsync数据同步服务
SSH连接原理及ssh-key讲解
C语言I博客作业04
C语言l博客作业03
C语言I博客作业02
定义一个计算字符串高度的方法
字典转模型
UIScrollView和UIPageControl
原文地址:https://www.cnblogs.com/a121984376/p/1245886.html
最新文章
图片预加载
基于jQuery + JSON 的级联选择效果
在线工具推荐
LNMP
PXE自动装机
MySQL
scp ssh-key连接原理
NFS
tomcat
LNMP
热门文章
nginx原理及使用
PXE 实现自动装机
Jumpserver跳板机的搭建和部署
初学Mysql
Nginx反向代理与负载均衡应用实践
Nginx详细讲解
jumpserver跳板机
LNMP搭建流程
备份全网服务器数据
Ansible批量自动化管理工具入门
Copyright © 2011-2022 走看看