<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>  <script type="text/javascript">
     function raClk(inc) {      document.getElementById("Hidden2").value+=inc.checked;
     }    </script></head>
<body>
    <form id="form1" runat="server">
 <div>
<input name="ra" type="radio" value="A"  onclick="raClk(this);"  />AAA
<input name="ra" type="radio" value="B" onclick="raClk(this);"/>BBB
<input name="ra" type="radio" value="C" onclick="raClk(this);"/>CCC
<div></div>

     <br /><input name="Hidden_name" id="Hidden2" type="hidden" value="" />   
     <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1"  /><br />
     &nbsp;</div></form>
</body>
</html>
他的效果就是把每个按钮点一下他就会加到隐藏域里面去 怎么改才只获得当前的被选中的

解决方案 »

  1.   

     document.getElementById("Hidden2").value+=inc.checked;
    你这个我没弄明白 能解释下吗
      

  2.   

    function raClk(inc) {             document.getElementById("Hidden2").value+=inc.value;
            }
      

  3.   

    难道就这么沉了??
    楼上的 你的方法 你自己试试就知道了。一道题选项有A B C 我都点一遍 那么隐藏域的值就是 abc
      

  4.   

    function raClk(inc) {             document.getElementById("Hidden2").value=inc.value;
            }
    不过这样貌似没啥用啊,提交后Hidden_name和ra的值一样
      

  5.   

    function raClk(inc) {             document.getElementById("Hidden2").value=inc.innerText;
            }
      

  6.   


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>  <script type="text/javascript">
            var obj;
            function raClk(inc) {
                 obj+=inc.value;
                 document.getElementById("Hidden2").value=obj;
            }    </script></head>
    <body>
        <form id="form1" runat="server">
     <div>
            <input name="ra" type="radio" value="A"  onclick="raClk(this);"  />AAA
            <input name="ra" type="radio" value="B" onclick="raClk(this);"/>BBB
            <input name="ra" type="radio" value="C" onclick="raClk(this);"/>CCC
            <div></div>
        
         <br /><input name="Hidden_name" id="Hidden2" type="hidden" value="" />   
         <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1"  /><br />
         &nbsp;</div></form>
    </body>
    </html>是不是这样额 你意思没弄明白
      

  7.   

                 document.getElementById("Hidden2").value+=inc.value;
      

  8.   

        document.getElementById("Hidden2").value=inc.value;