网页里有一个下拉列表和一个OK按钮,要求点击后下拉列表变成单选按钮。( 下拉列表的值给了单选按钮 )代码如下 :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function btnOKClientClick() {
          
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:DropDownList ID="DropDownList1" runat="server" Height="23px" Width="100px">
            <asp:ListItem >北京</asp:ListItem>
            <asp:ListItem >上海</asp:ListItem>
            <asp:ListItem >广州</asp:ListItem>
        </asp:DropDownList>
        <asp:Button ID="btnOk" runat="server" Height="19px" Text="OK" Width="48px" OnClientClick="btnOKClientClick()"/>
        <asp:RadioButton ID="RadioButton1" runat="server" />
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   


    function btnOKClientClick() {
    var selectValue = document.getElementById("DropDownList1").value;
    document.getElementById("RadioButton1").value = selectValue;
    }
      

  2.   

    点击OK按钮后,DropDownList,变成 RadioButton。(同时DropDownList里的ListItem值给RadioButton)。
      

  3.   

    什么RadioButton 创建个radio取相同名字不就行了 不知道难度在哪
      

  4.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
            function btnOKClientClick() {
               var rdo = "";
               $("#DropDownList1 option").each(function(){
                    rdo+= "<input type='radio' value='"+$(this).val()+"' name='city' />"+$(this).text();
               }); 
               $("#btnOk").after(rdo);               
               return false;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:DropDownList ID="DropDownList1" runat="server" Height="23px" Width="100px">
                <asp:ListItem Value="bj" >北京</asp:ListItem>
                <asp:ListItem Value="sh" >上海</asp:ListItem>
                <asp:ListItem Value="gz" >广州</asp:ListItem>
            </asp:DropDownList>
            <asp:Button ID="btnOk" runat="server" Height="19px" Text="OK" Width="48px" OnClientClick="return btnOKClientClick()"/>
        </div>
        </form>
    </body>
    </html>是不是要这样 。
      

  5.   

    对,是这意思,很3Q。
    有两个疑问:1.能否把 DropDownList 隐藏,只显示radio 
               2.$("#btnOk").after(rdo);  这段的能否给点解释,after起到什么作用。
      

  6.   

    1.document.getElementById("DropDownList1").style.visibility = "hidden";
    2.是在button后面添加一个radiobutton元素'rdo'
      

  7.   

    $("#DropDownList1").hide() 隐藏了 。
    $("#btnOk").after(rdo);  在#btnOk(就是那个按钮) 后面添加元素 。 rdo是拼的字符串 。
      

  8.   

    当点击按钮后,会立马出现radio ,然后会提交表单后又只显示DropDownList 和Button  ,有什么办法点击按钮后,就出现radio 和Button 呢?