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

NameSilo域名优惠码活动

NameSilo是通过之前的感恩节优惠活动中认识到这家注册商的,于是今天早上花了点时间专门了解了NameSilo优惠码和商家的详细信息。该商家只销售域名,他们家的域名销售价格还是中规中矩的,没有像godaddy域名标价和使用优惠之后的价格悬殊很大,而且其特色就是该域名平台提供免费的域名停放、免费隐私保护等功能。namesilo新注册域名价格列表,NameSilo官方网站:www.namesilo....

HostKvm新上联通CUVIP线路VPS,八折优惠后1G内存套餐$5.2/月起

最近上洛杉矶机房联通CUVIP线路主机的商家越来越多了,HostKvm也发来了新节点上线的邮件,适用全场8折优惠码,基于KVM架构,优惠后最低月付5.2美元起。HostKvm是一家成立于2013年的国人主机商,提供基于KVM架构的VPS主机,可选数据中心包括日本、新加坡、韩国、美国、中国香港等多个地区机房,君选择国内直连或优化线路,延迟较低,适合建站或者远程办公等。以洛杉矶CUVIP线路主机为例,...

美国云服务器 1核 1G 100M 10G防御 39元/月 物语云计算

物语云计算(MonogatariCloud)是一家成立于2016年的老牌国人商家,主营国内游戏高防独服业务,拥有多家机房资源,产品质量过硬,颇有一定口碑。本次带来的是美国圣何塞 Equinix 机房的高性能I9-10980XE大带宽VPS,去程CN2GIA回程AS9929,美国原生IP,支持解锁奈飞等应用,支持免费安装Windows系统。值得注意的是,物语云采用的虚拟化技术为Hyper-V,资源全...

radio选中为你推荐
qq博客怎么开QQ博客啊!什么是生态系统生态系统的我主要特征是什么?电子邮件软件电子邮件软件哪个好用embed函数C语言中push函数的定义以及用法。软件开发技术文档软件开发技术的目录第三方支付系统→第三方支付平台有哪些视频比特率是什么视频中的码率是什么意思呢?起凡注册起凡怎么下 ?鸿道集团不是说收回了商标权了吗?为什么红罐王老吉还有“王老吉”三个字?红罐不是属于鸿道公司的么?语音合成系统请问哪一种语音合成软件好?
怎样申请域名 韩国俄罗斯 Hello图床 好看的留言 正版win8.1升级win10 购买国外空间 闪讯官网 yundun 国内域名 免费网络 wordpress中文主题 免费网络空间 97rb 空间排行榜 ubuntu安装教程 服务器是什么 压力测试工具 装修瓦工培训 宿主机 主机响 更多