zoukankan
html css js c++ java
JS取得RadioButtonList的Value,Text及选中值等信息
HTML部分
--------
Code
<
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:ListItem
Value
="5"
Text
="A5"
></
asp:ListItem
>
<
asp:ListItem
Value
="6"
Text
="A6"
></
asp:ListItem
>
<
asp:ListItem
Value
="7"
Text
="A7"
></
asp:ListItem
>
<
asp:ListItem
Value
="8"
Text
="A8"
></
asp:ListItem
>
<
asp:ListItem
Value
="9"
Text
="A9"
></
asp:ListItem
>
<
asp:ListItem
Value
="10"
Text
="A10"
></
asp:ListItem
>
</
asp:RadioButtonList
>
<
input
id
="Button1"
type
="button"
value
="button"
onclick
="fn_GetRadioButtonListInfo();"
/>
JS部分
-------
Code
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
;
}
查看全文
相关阅读:
git命令_保存本地变更+拉取+合并代码+推送代码到远程仓+添加CI触发器变量
debian_linux_apt-get命令_dpkg命令
debian_linux系统_访问真实环境rancher_证书问题相关_https相关_使用kubectl命令行查看资源时报错:Unable to connect to the server: x509: certificate signed by unknown authority
linux_xargs入门介绍_及和for循环命令区别
技术实践丨GaussDB(DWS)运维管理功能“升级”的原理和使用
华为云数据安全中心正式公测,8大核心数据安全能力守护你的数据
华为鲲鹏专家解读:90%代码如何移植到鲲鹏平台
数据库技术丨GaussDB(DWS)数据同步状态查看方法
你掉进过“伪敏捷”的陷阱吗?
拯救深度学习:标注数据不足下的深度学习方法
原文地址:https://www.cnblogs.com/freeliver54/p/1126831.html
最新文章
抖音影视剪辑5种赚钱方法、18个素材网站、8.0剪辑方法防判搬运
Rolf Dobelli 《清醒思考的艺术》
张磊《价值》30则金句
谷歌中国跨境电商总监经验谈
解密 Snapchat | 社交产品三段论
qt--setAttribute设置窗口属性
MessageBox消息框
WinMain函数
C++priority_queue优先队列
C++容器
热门文章
qt---win32
控制台CMD
C++--CMD中文乱码
qt--硬件序列号
c# HttpClient 发送请求出错时解决办法
Visual Studio保存时自动格式化代码的坑?
c# – 因为算法不同,客户端和服务器无法通信
JS-iframe-跨窗口通讯
C#使用Linq to csv读取.csv文件数据3_源码改造_支持设置标题行&标题映射&自动打印并忽略错误行数据&定义数据格式
MySQL too many connections 之解决方法
Copyright © 2011-2022 走看看