下拉框、单选框都可以用form.xxx.value,几个单选框用同一个名字。

解决方案 »

  1.   

    单选框都用form.xxx.value不行我试过了
      

  2.   


    单选框radionname[i].checked
    radionname[i].value<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>
    下拉框用selectname.options[selectedIndex].value