同名radio的取值

1<input name="sex" selected="" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="???" type="button"/>

如何取sex的value?

---------------------------------------------------------------

 1<script>   
 2function aa()   
 3{   
 4l=document.getElementsByName("sex")   
 5for(i=0;i<l.length;i++)   
 6{   
 7if(l[i].checked) alert(l[i].value)   
 8}   
 9}   
10</script>
1<input name="sex" selected="" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="aa()" type="button"/>

---------------------------------------------------------------

1<input name="r" type="radio" value="1"/>
1<input name="r" type="radio" value="2"/>
1<input name="r" type="radio" value="3"/>
1<input onclick="for(i=0;i&lt;r.length;i++)alert(r[i].value)" type="submit"/>

---------------------------------------------------------------

1<input checked="" name="sex" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="for(var i=0;i&lt;sex.length;i++){if(sex[i].checked)alert('your select:'+sex[i].value)}" type="button"/>

---------------------------------------------------------------

1<input checked="" name="sex" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="for(i=0;i&lt;sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" type="button" value="sumit"/>

---------------------------------------------------------------

1<input checked="" name="sex" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="for(i=0;i&lt;sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" type="button" value="sumit"/>

---------------------------------------------------------------

1<input checked="" name="sex" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="for(i=0;i&lt;sex.length;i++){if(sex[i].checked)alert(sex[i].value)}" type="button" value="submit"/>

---------------------------------------------------------------

1<input name="sex" selected="" type="radio" value="1"/>

1<input name="sex" type="radio" value="0"/>

1<input onclick="javascript:alert(sex.value)" type="button"/>
Published At
Categories with Web编程
comments powered by Disqus