troubleshooting Question

How do I get a horizontally oriented radiobuttonlist to make a dropdownlist visible or hidden using javascript?

Avatar of jazjef
jazjef asked on
JavaScript.NET ProgrammingASP.NET
2 Comments1 Solution1496 ViewsLast Modified:
My tools:  Visual Web Developer, VB.net backcoding

This script works fine at the outset, but whenever I change the radiobuttonlist to 'horizontal' orientation within Visual Web Developer 'properties' the script does not work. If I change it back, then it still doesn't work. Can anyone give me a method to do this using a 'horizontally' oriented two-option radiobuttonlist rather than this vertical orientation?

Thanks.....


<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Jscript_VB.NET_TOOLS</title>
   
<script language="javascript">
/////////////////////////////////////////////////////////////////
//hide the dropdownlist on pageload...
function function_StartHidden()
{
     document.getElementById("myddl").style.display = "none";

}    

window.onload= function_StartHidden;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</script>

<script type="text/javascript">
//////////////////////////////////////////////////////////////////
//show the dropdownlist...
function ShowDropDown()
{
     document.getElementById("myddl").style.display = "inline";
}
////hide the dropdownlist
function HideDropDown()
{
     document.getElementById("myddl").style.display = "none";
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</script>
   
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Choose 'pn1' to make the dropdownlist visible; choose 'pn2' to hide the dropdownlist.....<br />
        <br />
        <asp:DropDownList ID="myddl" runat="server" Width="88px">
            <asp:ListItem>item 1</asp:ListItem>
            <asp:ListItem>item 2</asp:ListItem>
            <asp:ListItem>item 3</asp:ListItem>
            <asp:ListItem>item 4</asp:ListItem>
        </asp:DropDownList>&nbsp;<br />
        <br />
        Here we have a radiobuttonlist:<br />
        <asp:radiobuttonlist runat="Server" id="rbl">
        <asp:listitem onclick="ShowDropDown()">pn1</asp:listitem>
        <asp:listitem onclick="HideDropDown()">pn2</asp:listitem>
        </asp:radiobuttonlist>
        <br />

    </div>
    </form>
</body>
</html>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros