<script>
function get_radio_value (radio_array){
var i;
for (i=0;i<radio_array.length;++i) //radio_array.length是radio选项的个数
if (radio_array[i].checked)
return radio_array[i].value;
return null; //如果一项都没选则返回空值
}
</script>
<form>
What is your favorite fruit?<br>
<input type=radio name=fruit value=apple>apple<br>
<input type=radio name=fruit value=orange>orange<br>
<input type=radio name=fruit value=banana>banana<br>
<input type=radio name=fruit value=other>other
<input type=text name=echotext>
<input type=button value=echo onClick="form.echotext.value = get_radio_value (form.fruit);">
<input type=reset value=clear>
</form>
function get_radio_value (radio_array){
var i;
for (i=0;i<radio_array.length;++i) //radio_array.length是radio选项的个数
if (radio_array[i].checked)
return radio_array[i].value;
return null; //如果一项都没选则返回空值
}
</script>
<form>
What is your favorite fruit?<br>
<input type=radio name=fruit value=apple>apple<br>
<input type=radio name=fruit value=orange>orange<br>
<input type=radio name=fruit value=banana>banana<br>
<input type=radio name=fruit value=other>other
<input type=text name=echotext>
<input type=button value=echo onClick="form.echotext.value = get_radio_value (form.fruit);">
<input type=reset value=clear>
</form>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货