问个问题,单选按钮的问题,
假如单选按钮A和B
单选按钮我设置默认选中的为A我创建用户的时候选择的A,
但是,我查看用户信息的时候,我改成了B,点确定。
之后再查看用户的信息,单选按钮还是默认的A,怎么让单选按钮默认为我所中的。最好给个例子,谢谢。

解决方案 »

  1.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <script type="text/javascript">
            var select="a";
            function setradio(){
                var list=document.getElementsByName("rad");
                for(var i=0;i<list.length;i++)
                {
                    if(list[i].value==select)
                    {
                        list[i].checked=true;
                        break;
                    }
                }
            }
        </script>
    </head>
    <body onload="setradio();">
        <form id="form1" runat="server">
        <div>
            <input type="radio" value="a" name="rad" />A
            <input type="radio" value="b" name="rad" />B
        </div>
        </form>
    </body>
    </html>
     //select的值为你要默认选中的value