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被选中相关文档

BGPTO独服折优惠- 日本独服65折 新加坡独服75折

BGPTO是一家成立于2017年的国人主机商,从商家背景上是国内的K总和有其他投资者共同创办的商家,主营是独立服务器业务。数据中心包括美国洛杉矶Cera、新加坡、日本大阪和香港数据中心的服务器。商家对所销售服务器产品拥有自主硬件和IP资源,支持Linux和Windows。这个月,有看到商家BGPTO日本和新加坡机房独服正进行优惠促销,折扣最低65折。第一、商家机房优惠券码这次商家的活动机房是新加坡...

CloudCone闪购优惠洛杉矶MC机房VPS月$1.99 便宜可随意删除重开

CloudCone商家我们很多喜欢低价便宜VPS主机的肯定是熟悉的,个人不是特别喜欢他。因为我之前测试过几次,开通的机器IP都是不通的,需要删除且开通好几次才能得到一个可用的IP地址。当然他们家的优势也是有的,就是价格确实便宜,而且还支持删除重新开通,而且机房只有一个洛杉矶MC。实话,如果他们家能多几个机房,保持现在的特点,还是有很多市场的。CloudCone是来自美国的主机销售商,成立于2017...

Hostodo,美国独立日特价优惠,四款特价VPS云服务器7折,KVM虚拟架构,NVMe阵列,1核512M内存1Gbps带宽3T月流量,13.99美元/月,赠送DirectAdmin授权

Hostodo近日发布了美国独立日优惠促销活动,主要推送了四款特价优惠便宜的VPS云服务器产品,基于KVM虚拟架构,NVMe阵列,1Gbps带宽,默认分配一个IPv4+/64 IPv6,采用solusvm管理,赠送收费版DirectAdmin授权,服务有效期内均有效,大致约为7折优惠,独立日活动时间不定,活动机型售罄为止,有需要的朋友可以尝试一下。Hostodo怎么样?Hostodo服务器好不好?...

radio选中为你推荐
elemtypedef和Elem是什么意思?(数据结构)chrome系统谷歌Chrome OS可以用来做什么?qq博客怎样开通QQ博客?搜索引擎的概念搜索引擎营销的概念是什么?模式识别算法模式识别的简史印度尼西亚国家代码谁知道世界各国的国家电话代码?审计平台什么是审计工具微信智能机器人微信群机器人是怎么实现的kjava谁能告诉我KJAVA是什么意思和普通的JAVA程序有什么区别?bt代理有人推荐我成为btbank代理人,这个没有什么风险?
武汉域名注册 移动服务器租用 联通vps 主机优惠码 双12活动 智能骨干网 腾讯云分析 idc资讯 cdn加速原理 东莞服务器 最漂亮的qq空间 cloudlink 百度云加速 dnspod 英国伦敦 韩国代理ip 防cc攻击 主机返佣 稳定空间 nnt 更多