|
-
Jan 8th, 2009, 11:14 AM
#1
Thread Starter
Fanatic Member
[resolved] show / hide panel
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
Last edited by staticbob; Jan 19th, 2009 at 05:06 AM.
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Jan 8th, 2009, 01:28 PM
#2
Re: show / hide panel
How about
$get('panelID').style.display='none' // for hide
$get('panelID').style.display='block' // for show
-
Jan 8th, 2009, 01:48 PM
#3
Re: show / hide panel
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>
-
Jan 9th, 2009, 06:54 AM
#4
Thread Starter
Fanatic Member
Re: show / hide panel
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 dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Jan 9th, 2009, 09:25 AM
#5
Re: show / hide panel
]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.
-
Jan 19th, 2009, 05:05 AM
#6
Thread Starter
Fanatic Member
Re: show / hide panel
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.
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|