javascript当中radio的用法



例 5.1(RadioReferenceIEFF.html)
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <TITLE></TITLE>
    <SCRIPT LANGUAGE="JavaScript">
        function clickH()
        {
            var form = document.forms[0];
 
            if (form.school[0].checked)
            {
                form.school[1].checked = true;
            }
        }
    </SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="">
    清华<INPUT TYPE="radio" NAME="school" value="th" checked><br>
    北大<INPUT TYPE="radio" NAME="school" value="bd"><br>
    <INPUT  TYPE="button" value="变" onClick="clickH()"/>
</FORM>
</BODY>
</HTML>





例 5.2(RadioReference2IEFF.html)




<HTML>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</HEAD>
<BODY>
<FORM onClick="handleClick()">
    <INPUT TYPE="radio" VALUE="A" NAME="SET">Selection A<BR>
    <INPUT TYPE="radio" VALUE="B" NAME="SET">Selection B<BR>
    <INPUT TYPE="radio" VALUE="C" NAME="SET">Selection C<BR>
    <INPUT TYPE="radio" VALUE="D" NAME="SET">Selection D<BR>
    <INPUT TYPE="text"  VALUE="D"><BR>
</FORM>
<SCRIPT>

    function handleClick()
    {
        /*
         If the radio button has a mark in it (it is the only one of the family it belongs to that is selected), then this value will return true. Otherwise it will return false.
         */
         alert(document.forms[0].elements[0].checked);
    }
</SCRIPT>
</BODY>
</HTML>