Guys,
Simple one...
I want to show or hide a panel when I click on a label on my aspx page. Does anybody have the javascript to do this? I know its simple but its been a while...
Thanks
Bob
Printable View
Guys,
Simple one...
I want to show or hide a panel when I click on a label on my aspx page. Does anybody have the javascript to do this? I know its simple but its been a while...
Thanks
Bob
How about
$get('panelID').style.display='none' // for hide
$get('panelID').style.display='block' // for show
Try this:
Code:<html>
<head>
<script type="text/javascript">
function toggleVisible(){
var x=document.getElementById('MyDiv');
if (x) x.style.display=(x.style.display=='none')?'block':'none';
}
</script>
</head>
<body>
<div id='MyDiv' style='background-color:red'>
<h1>The div I want to hide/show</h1>
</div>
<p>Click on the button to show/hide the div</p>
<input type='button' value='Click Here' onclick='toggleVisible()'></input>
</body>
</html>
Thanks guys.
I now have this but its not working, what did I miss???
Bob
HTML Code:<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<script type="text/javascript">
function toggleVisible(){
var x=document.getElementById('Panel1');
if (x) x.style.display=(x.style.display=='none')?'block':'none';
}
</script>
<body>
<form id="form1" runat="server">
<div>
<input type='button' value='Click Here' onclick='toggleVisible()'></input>
<br />
<uc2:ctl_section ID="ctl_section1" runat="server" Visible="True" />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
]I see a couple things.
- The javascript should be inside the head
- The item you are trying to toggle the visiblity is Panel1. I don't see that anywhere in your code.
Thanks for the responses guys, I've now moved to the ajax accordion control, implementing it as a listview hosting my custom controls. Works a treat.