Link to home
Start Free TrialLog in
Avatar of jazjef
jazjef

asked on

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

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>
ASKER CERTIFIED SOLUTION
Avatar of Chirag1211
Chirag1211
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jazjef
jazjef

ASKER

Chirag:

Thanks.... that works great!

Can you explain to me why changing the radiobuttonlist orientation to 'horizontal' within the 'properties' section of the design area does not work, but adding RepeatDirection="Horizontal" directly into the html  of the control does work?