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
;
}
查看全文
相关阅读:
JavaScript进阶-BOM和DOM
JavaScript基础
CSS2-属性
CSS1-选择器
HTML-常用标签
判断回文
课堂作业
动手动脑
原码反码补码
Java第一次考试作业
原文地址:https://www.cnblogs.com/a121984376/p/1245886.html
最新文章
【BZOJ4318】OSU! 题解(期望)
【NOI2005】聪聪与可可 题解(最短路+期望DP)
【SCOI2008】奖励关 题解(状压DP+期望)
【SDOI2010】猪国杀 题解(模拟)
JavaSE 基础 第32节 三大特性之继承
JavaSE 基础 第31节 三大特性之封装
JavaSE 基础 第30节 包
JavaSE 基础 第29节 final 关键字
JavaSE 基础 第28节 static 关键字
JavaSE 基础 第27节 对象类型的参数传递
热门文章
JavaSE 基础 第26节 构造方法重载
JavaSE 基础 第25节 对象的创建和使用
JavaSE 基础 第24节 方法的重载
JavaSE 基础 第23节 构造方法
flask的基本搭建
Django进阶-模板系统
Django进阶-ORM操作
Django2-配置文件
Django1-web概述与django基本操作
jQuery快速入门
Copyright © 2011-2022 走看看