radio选中如何判断是哪个radio被选中

radio选中  时间:2021-06-05  阅读:()

radiobutton 怎么获取选中状态

用savedInstanceState,代码如下: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button) findViewById(R.id.button); RadioButton radiobutton1 = (RadioButton) findViewById(R.id.radiobutton1); RadioButton radiobutton2 = (RadioButton) findViewById(R.id.radiobutton2); if (savedInstanceState != null) { boolean tmp1 = savedInstanceState.getBoolean("radio1"); if (tmp1) { radiobutton1.setChecked(true); } boolean tmp2 = savedInstanceState.getBoolean("radio2"); if (tmp2) { radiobutton2.setChecked(true); } } if (IsRadioButton1Selected) { radiobutton1.setChecked(true); } if (IsRadioButton2Selected) { radiobutton2.setChecked(true); } button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent it = new Intent(MainActivity.this, SecondActivity.class); startActivity(it); } }); } @Override protected void onSaveInstanceState(Bundle outState) { RadioButton radiobutton1 = (RadioButton) findViewById(R.id.radiobutton1); RadioButton radiobutton2 = (RadioButton) findViewById(R.id.radiobutton2); if (radiobutton1.isChecked()) { IsRadioButton1Selected = true; } else if (radiobutton2.isChecked()) { IsRadioButton2Selected = true; } else Toast.makeText(this, "nothing selected", Toast.LENGTH_SHORT).show(); outState.putBoolean("radio1", IsRadioButton1Selected); outState.putBoolean("radio2", IsRadioButton2Selected); super.onSaveInstanceState(outState); }   更多0

javascript中判断radio是否被选中

可以直接用javascript里面radio自带属性checked,去判断radio是否被选中。

<br>下面是代码,仅供参考;<br>&lt;html&gt;<br>&lt;script?type=&quot;text/javascript&quot;&gt;<br>function?selectradio()<br>{<br>????var?arr=document.getElementsByName(&quot;radio1&quot;);<br>????for(var?i=0;i&lt;arr.length;i++)<br>????{<br>????????if(arr[i].checked)<br>????????{<br>????????????alert(arr[i].value)<br>????????}<br>????}<br>}<br>function?selectcheck()<br>{<br>????var?=document.getElementsByName(&quot;checkbox1&quot;);<br>????var?str=&quot;&quot;;<br>????for(var?i=0;i&lt;.length;i++)<br>????{<br>????????if(arr[i].checked)<br>????????{<br>????????????str+=[i].value+&quot;,&quot;;<br>????????}<br>????????alert(str);<br>????}<br>}<br>function?selectselect()<br>{<br>????var?ass=document.getElementById(&quot;select1&quot;);<br>????alert(ass.options[ass.selectedIndex].text+&quot;:&quot;+ass.options[ass.selectedIndex].value);<br>}<br>&lt;/script&gt;<br>&lt;body&gt;<br>&lt;div?align=&quot;center&quot;&gt;<br>&lt;form&gt;<br>????&lt;input?type=&quot;radio&quot;?name=&quot;radio1&quot;?value=&quot;111&quot;?/&gt;&lt;br/&gt;<br>????&lt;input?type=&quot;radio&quot;?name=&quot;radio1&quot;?value=&quot;222&quot;?/&gt;&lt;br/&gt;<br>????&lt;input?type=&quot;radio&quot;?name=&quot;raido1&quot;?value=&quot;333&quot;?/&gt;&lt;br/&gt;<br>????&lt;input?type=&quot;button&quot;?name=&quot;submit2&quot;?value=&quot;&quot;?/&gt;<br>????&lt;br/&gt;<br>????&lt;br/&gt;<br>????&lt;input?type=&quot;checkbox&quot;?name=&quot;checkbox1&quot;?value=&quot;111&quot;?/&gt;&lt;br/&gt;<br>????&lt;input?type=&quot;checkbox&quot;?name=&quot;checkbox1&quot;?value=&quot;222&quot;?/&gt;&lt;br/&gt;<br>????&lt;input?type=&quot;checkbox&quot;?name=&quot;checkbox1&quot;?value=&quot;333&quot;?/&gt;&lt;br/&gt;<br>????&lt;input?type=&quot;button&quot;?name=&quot;submit&quot;?vlaue=&quot;按钮&quot;?/&gt;<br>????&lt;br/&gt;<br>????&lt;br/&gt;<br>????&lt;select?name=&quot;select&quot;?id=&quot;select1&quot;&gt;<br>????????&lt;option?value=&quot;111&quot;&gt;第一项&lt;/option&gt;<br>????????&lt;option?value=&quot;222&quot;&gt;第二项&lt;/option&gt;<br>????????&lt;option?value=&quot;333&quot;&gt;第三项&lt;/option&gt;<br>????&lt;/select&gt;<br>????&lt;input?type=&quot;button:&quot;?name=&quot;submit3&quot;?value=&quot;按钮&quot;?/&gt;<br>????&lt;br/&gt;<br>????&lt;br/&gt;<br>&lt;/form&gt;<br>&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;

jquery radio 是否选中

//?判断id为radioId的radio是否选中 if($("#radioId:checked")[0]){ console.log("选中"); }else{ console.log("未选中"); }希望对你有帮助!

如何判断是哪个radio被选中

$(&quot;:radio&quot;).each(function(){<br>if($(this).attr(&quot;checked&quot;)){<br>alert(&quot;选中&quot;);<br>}else{<br>alert(&quot;未选中&quot;);<br>}<br>})

  • radio选中如何判断是哪个radio被选中相关文档

哪个好Vultr搬瓦工和Vultr97%,搬瓦工和Vultr全方位比较!

搬瓦工和Vultr哪个好?搬瓦工和Vultr都是非常火爆的国外VPS,可以说是国内网友买的最多的两家,那么搬瓦工和Vultr哪个好?如果要选择VPS,首先我们要考虑成本、服务器质量以及产品的售后服务。老玩家都知道目前在国内最受欢迎的国外VPS服务商vultr和搬瓦工口碑都很不错。搬瓦工和Vultr哪个稳定?搬瓦工和Vultr哪个速度快?为了回答这些问题,本文从线路、速度、功能、售后等多方面对比这两...

Hostodo:$34.99/年KVM-2.5GB/25G NVMe/8TB/3个数据中心

Hostodo在九月份又发布了两款特别套餐,开设在美国拉斯维加斯、迈阿密和斯波坎机房,基于KVM架构,采用NVMe SSD高性能磁盘,最低1.5GB内存8TB月流量套餐年付34.99美元起。Hostodo是一家成立于2014年的国外VPS主机商,主打低价VPS套餐且年付为主,基于OpenVZ和KVM架构,美国三个地区机房,支持支付宝或者PayPal、加密货币等付款。下面列出这两款主机配置信息。CP...

iHostART:罗马尼亚VPS/无视DMCA抗投诉vps;2核4G/40GB SSD/100M端口月流量2TB,€20/年

ihostart怎么样?ihostart是一家国外新商家,主要提供cPanel主机、KVM VPS、大硬盘存储VPS和独立服务器,数据中心位于罗马尼亚,官方明确说明无视DMCA,对版权内容较为宽松。有需要的可以关注一下。目前,iHostART给出了罗马尼亚vps的优惠信息,罗马尼亚VPS无视DMCA、抗投诉vps/2核4G内存/40GB SSD/100M端口月流量2TB,€20/年。点击直达:ih...

radio选中为你推荐
vga接口定义VGA接口通常用来连接哪些设备,各个脚代表什么意思,它的连线是如何焊接的?awvawv格式是否等于MP4格式jstz举手望,草上马跑,打什么数字?数据挖掘项目什么是数据挖掘?从事相关的工作有什么要求?天翼校园宽带中国电信校园宽带怎么样?什么是生态系统生态系统的我主要特征是什么?kjava谁能告诉我KJAVA是什么意思和普通的JAVA程序有什么区别?kjava通用KJava是什么意思中信银行理财宝中信银行理财宝可以长期存款吗?点心os什么是点心os?手机操作系统和手机区别么?一个是硬件一个是软件?听说炒的好火?
云主机租用 国外虚拟空间 万网免费域名 联通c套餐 ion dreamhost ix主机 dropbox网盘 搜狗12306抢票助手 卡巴斯基永久免费版 域名转向 谁的qq空间最好看 如何建立邮箱 atom处理器 卡巴斯基官网下载 闪讯网 privatetracker 亿库 stealthy 天鹰抗ddos防火墙 更多