473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

show/hide thingy

I'd like to have a show/hide widget on my web site, kind of like "show
details" / "hide details" in Google Groups. Is there a tutorial
explaining how to make them? Google's is a bit complex and it's easy to
get something wrong. If the browser does not support the required
features, I want it to generate a completely static page with the
"details" shown automatically.

Sep 6 '05 #1
3 2915
alex wrote:
I'd like to have a show/hide widget on my web site, kind of like "show
details" / "hide details" in Google Groups. Is there a tutorial
explaining how to make them? Google's is a bit complex and it's easy to
get something wrong. If the browser does not support the required
features, I want it to generate a completely static page with the
"details" shown automatically.

Hi Alex

It's very trivial to create this consider the following:
---------------------- JAVASCRIPT -----------------------
function Show(){
document.getElementById( "Details" ).style.display = "block";
document.getElementById( "ButtonShow" ).style.display = "none";

}
function Hide(){
document.getElementById( "Details" ).style.display = "none";
document.getElementById( "ButtonShow" ).style.display = "block";
}
---------------------------------------------------------

------------------------ HTML ---------------------------
<div id="ButtonShow" onclick="Show();">Show Details</div>
<div id="Details">
<div onclick="Hide();">Hide Details</div>
<p>This is the details...</p>
</div>
---------------------------------------------------------

------------------------ CSS ---------------------------
#Details { display:none; }
---------------------------------------------------------

I have expanded the code quite a bit to make it more simple.

To start, using CSS, I hide the the Details element, I have used display
and not the visibility property as visibility will not free the space
taken up by the element.

Then there are two functions Show and Hide. By Using the elements Id I
reference both the button and the details area and change the display
property of the style object.

As you can see I have included the hide button in the details element so
that it will appear and disappear along with the details. But it could
have been yet another element that you could have referenced.

This method will work an all modern browsers. IE/FireFox/Opera/Safari.
Hope this helps

Andy

----------------------------------------------------------------------
http://km0ti0n.blunted.co.uk/blog
http://km0ti0n.blunted.co.uk/mozXPath
http://km0ti0n.blunted.co.uk
----------------------------------------------------------------------


Sep 6 '05 #2
Andrew Scott wrote:
To start, using CSS, I hide the the Details element


This doesn't work well for browsers without javascript support.

If the details are initially hidden, then javascript should go through and
hide them on page load.

For example, this is a "sliding" div toggler that I wrote as an experiment a
while ago:
http://mattkruse.com/temp/togglediv.html

It should meet the OP's requirements, I think.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Sep 6 '05 #3
Matt Kruse wrote:
Andrew Scott wrote:
To start, using CSS, I hide the the Details element


This doesn't work well for browsers without javascript support.

If the details are initially hidden, then javascript should go through and
hide them on page load.

For example, this is a "sliding" div toggler that I wrote as an experiment a
while ago:
http://mattkruse.com/temp/togglediv.html

It should meet the OP's requirements, I think.


Thanks for sharing your code. There is a couple of problems with it,
IMHO:

* Clicking on a link to open a new tab / window will result in
frustation. A site visitor might think the link does not work. The link
itself might explicitly tell the user not to do that, but that's not
intuitive and distracting from the actual content

* Long lines get cut off (If you have a large paragraph instead of an
array of short lines separated by <BR>, only one line is shown with
most of the content hidden)

There was something else, but I forget right now.

Sep 7 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
4
by: Konrad Viltersten | last post by:
As it isnow i have to use a syntax for my tables as: <table class = "some" border> and/or <table class = "some" noborder> Now, what i'd like to do is to make that border-thingy...
0
by: Efkas | last post by:
I have a full custom application with some widged extending Controls like Label and PictureBox. I build a menu with these widgets. When I click on one of them, it calls a function to display...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.