473,394 Members | 1,785 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,394 software developers and data experts.

Toggle on/off

Hi folks. Sorry for the semi-cross-posting in the CSS group. I have a
question with regards to turning on and off a div.

I am doing AJAX calls for comments on a topic. Upon clicking, comments
are looked up for that record, and presented below the item. Initally,
that div has a unique id, so it's difficult to target, but I can find
it using some passed parameters.

When it is first created, there is no attribute set to display. So
display essentially = "". I want to modify the div id so that the
comments are then hidden. The problem is, the only choice I have is to
set the display to "none", which collapses the whole area, so the
original display is somewhat collapsed as well.

Is there any way I can keep the structure of the div, but hide its
contents, without collapsing its original entry?

This is difficult to explain. Just trying to find a display option for
a div that doesn't destroy the structure that I need.

Cheers

Jun 29 '06 #1
7 1851
BeeRich wrote:
Hi folks. Sorry for the semi-cross-posting in the CSS group. I have a
question with regards to turning on and off a div.

I am doing AJAX calls for comments on a topic. Upon clicking, comments
are looked up for that record, and presented below the item. Initally,
that div has a unique id, so it's difficult to target, but I can find
it using some passed parameters.

When it is first created, there is no attribute set to display. So
display essentially = "". I want to modify the div id so that the
comments are then hidden. The problem is, the only choice I have is to
set the display to "none", which collapses the whole area, so the
original display is somewhat collapsed as well.

Is there any way I can keep the structure of the div, but hide its
contents, without collapsing its original entry?

This is difficult to explain. Just trying to find a display option for
a div that doesn't destroy the structure that I need.

Cheers


Can you just do visibility:hidden for the div? (this should keep the
div from being removed from the layout like display:none does - it
should maintain the document's flow)
Jun 29 '06 #2
BeeRich wrote:
Hi folks. Sorry for the semi-cross-posting in the CSS group. I have a
question with regards to turning on and off a div. <...> This is difficult to explain. Just trying to find a display option for
a div that doesn't destroy the structure that I need.


Perhaps it would be easier to explain with a link & sample?

Based on what you say, you have this:

<div id="something">
<div>this is DIV1</div>
<div>this is DIV2</div>
<div>this is DIV3</div>
</div>

And you want to show/hide just DIV1 - is that a correct assessment, or
did I totally misread what you want?

--
"The most convoluted explanation that fits all of the made-up facts is
the most likely to be believed by conspiracy theorists. Fitting the
actual facts is optional."
Jun 29 '06 #3
Hi Brian. I never thought of that. I'll give it a whirl tonight.

Jun 29 '06 #4
Hi Tony. Thanks for the reply. Unfortunately I can't post. But I can
explain.

<div class="location">LOCATION1 WITH JS ONCLICK CALL</div>
<div id="comment1"></div>

Upon clicking of LOCATION1, an AJAX call fills comment1. The div fills
below as expected. Upon clicking LOCATION1 again, I want to return the
comment1 div back to its original state. Since my options were to set
its display to "none", the whole thing disappeared, having an accordion
effect on the stuff that is below these two lines.

I will try setting visibility from visible to hidden.

Cheers


Tony wrote:
BeeRich wrote:
Hi folks. Sorry for the semi-cross-posting in the CSS group. I have a
question with regards to turning on and off a div.

<...>
This is difficult to explain. Just trying to find a display option for
a div that doesn't destroy the structure that I need.


Perhaps it would be easier to explain with a link & sample?

Based on what you say, you have this:

<div id="something">
<div>this is DIV1</div>
<div>this is DIV2</div>
<div>this is DIV3</div>
</div>

And you want to show/hide just DIV1 - is that a correct assessment, or
did I totally misread what you want?

--
"The most convoluted explanation that fits all of the made-up facts is
the most likely to be believed by conspiracy theorists. Fitting the
actual facts is optional."


Jun 29 '06 #5
Unfortunately that didn't show anything in FireFox, Brian. No errors
as well. Thanks for the idea though. It appears that the text would
go hidden, but the space wouldn't collapse either, so that is a cousin
of display:none.

Cheers

BeeRich wrote:
Hi Brian. I never thought of that. I'll give it a whirl tonight.


Jun 29 '06 #6
BeeRich wrote:
Hi Tony. Thanks for the reply. Unfortunately I can't post. But I can
explain.
Just a note - it is generally considered better to respond at the
bottom, or to interlave your responses (as I am here) - it provides
better context.
<div class="location">LOCATION1 WITH JS ONCLICK CALL</div>
<div id="comment1"></div>

Upon clicking of LOCATION1, an AJAX call fills comment1. The div fills
below as expected. Upon clicking LOCATION1 again, I want to return the
comment1 div back to its original state. Since my options were to set
its display to "none", the whole thing disappeared, having an accordion
effect on the stuff that is below these two lines.
OK - so as I understand it, then, comment1 exists before you make the
ajax call. You then make the call & put the response into comment1.
Using innerHTML, by any chance?

How about:
document.getElementById('comment1').innerHTML = '';

That will clear the div but keep it in its place - now empty.
I will try setting visibility from visible to hidden.


That will preserve all the space for the DIV, but make it unseen. That
may do what you want.
--
"The most convoluted explanation that fits all of the made-up facts is
the most likely to be believed by conspiracy theorists. Fitting the
actual facts is optional."
Jun 30 '06 #7
Hi Tony. I got it to work. I went back to the display: none routine.
I'm relatively new to JS, so my previous attempts got me messing up my
IF routine.

Cheers

Jun 30 '06 #8

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

Similar topics

2
by: leegold2 | last post by:
I wondered if anyone would give me code- I think it would be easy, but I'm a complete newbie. What I want to do is to show many tables in a brief truncated format and then for each table offer the...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
4
by: Neil Coleclough | last post by:
I am constructing a database to process product returns for my Company. I have a number of toggle buttons to identify the stage to which each return has been processed. For example, clicking the...
5
by: Steven | last post by:
Can anyone tell me how to toggle the "Caps Lock" key? Thanks in advance
50
by: sksoule | last post by:
Hi, Can anyone please tell me how to toggle a nth bit. For example, I am having a variable which is of 8 bits. I want to toggle the nth bit. Regards, Santosh
1
by: barbalu | last post by:
Hello. I'm painfully new to this and am having trouble figuring out what I'm doing wrong... I have two small tables in a simple html file. I want each table to have the ability to collapse/expand...
3
by: Killer42 | last post by:
Hi all. I have a frame with some toggle buttons in it. All is working fine, except that the user can't tell which option is selected to begin with. How do I set one of the toggle buttons to the...
1
by: swiftouch | last post by:
I'm getting an error message in FF2.0: document.getElementById(toggle) has no properties The goal of the script is, when I hover my mouse over an image, to make one div element visible while...
0
by: ARC | last post by:
Hello all, In access 2007, it appears you cannot put a toggle button underneath a menu id and have it show a Pressed / Not Pressed status. If you make the toggleButton ID as part of the main...
4
by: ameshkin | last post by:
I have a checkbox with an ID of svc_tp_1, and an image that corresponds with this checkbox below it. <input type="checkbox" name="checkbox" id="svc_tp_1" value="svc_tp_1" / <img...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.