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

changing specific <div> status

I have <div id=box1 style="display:block"as the initial setting.
I need to change the "display:block" to "display:none" then back to
"display:block" as a means of clearing anything that might be
displayed within the box1 division.

What's the simplest way of doing this?
Nov 6 '08 #1
8 1852
rf

"richard" <me****@newsguy.comwrote in message
news:co********************************@4ax.com...
>I have <div id=box1 style="display:block"as the initial setting.
I need to change the "display:block" to "display:none" then back to
"display:block" as a means of clearing anything that might be
displayed within the box1 division.
Changing the display property as above will *not* achieve "clearing anything
that might be displayed".
Nov 6 '08 #2
On Thu, 06 Nov 2008 09:09:06 GMT, "rf" <rf@invalid.comwrote:
>
"richard" <me****@newsguy.comwrote in message
news:co********************************@4ax.com.. .
>>I have <div id=box1 style="display:block"as the initial setting.
I need to change the "display:block" to "display:none" then back to
"display:block" as a means of clearing anything that might be
displayed within the box1 division.

Changing the display property as above will *not* achieve "clearing anything
that might be displayed".
As I have found out this is true.
So what will?
Nov 6 '08 #3
rf

"richard" <me****@newsguy.comwrote in message
news:ch********************************@4ax.com...
On Thu, 06 Nov 2008 09:09:06 GMT, "rf" <rf@invalid.comwrote:
>>
"richard" <me****@newsguy.comwrote in message
news:co********************************@4ax.com. ..
>>>I have <div id=box1 style="display:block"as the initial setting.
I need to change the "display:block" to "display:none" then back to
"display:block" as a means of clearing anything that might be
displayed within the box1 division.

Changing the display property as above will *not* achieve "clearing
anything
that might be displayed".

As I have found out this is true.
So what will?
document.getElementById("box1").innerHTML = "";

but why? If you don't want stuff displayed in the div then don't put it in
there.
Nov 6 '08 #4
On Nov 6, 3:17*am, richard <mem...@newsguy.comwrote:
As I have found out this is true.
So what will?
What do you mean by "clearing anything that might be displayed"?

In other words, you are not merely interested in toggling the
visibility of the div, but you want to empty the contents of the div
also?

If that is what you're getting out, maybe consider altering the
innerHML attribute of the div.

someDiv.innerHTML = "";
Nov 6 '08 #5
On Thu, 06 Nov 2008 09:21:04 GMT, "rf" <rf@invalid.comwrote:
>
"richard" <me****@newsguy.comwrote in message
news:ch********************************@4ax.com.. .
>On Thu, 06 Nov 2008 09:09:06 GMT, "rf" <rf@invalid.comwrote:
>>>
"richard" <me****@newsguy.comwrote in message
news:co********************************@4ax.com ...
I have <div id=box1 style="display:block"as the initial setting.
I need to change the "display:block" to "display:none" then back to
"display:block" as a means of clearing anything that might be
displayed within the box1 division.

Changing the display property as above will *not* achieve "clearing
anything
that might be displayed".

As I have found out this is true.
So what will?

document.getElementById("box1").innerHTML = "";

but why? If you don't want stuff displayed in the div then don't put it in
there.
Now that, is the response I would expect from a 10 year old.

I am attempting to design a menu system that will that will have 3
levels of choices.
Yeah sure I could use those premade scripts that show your choices as
long as the cursor is over that item. But I need stability.

Item 1 has only one choice.
Items 2 and 3 will have two sublevels to choose from.
Item 4 will have one level.
All of which is contained within "box1".
What you see displayed is the content of your first level item choice.
So why show the others?
Of course, I could just as well write a seperate page for each choice
but that would mean keeping track of that many more pages.

Nov 6 '08 #6
On Thu, 6 Nov 2008 01:28:20 -0800 (PST), Doug Gunnoe
<do********@gmail.comwrote:
>On Nov 6, 3:17*am, richard <mem...@newsguy.comwrote:
>As I have found out this is true.
So what will?

What do you mean by "clearing anything that might be displayed"?

In other words, you are not merely interested in toggling the
visibility of the div, but you want to empty the contents of the div
also?

If that is what you're getting out, maybe consider altering the
innerHML attribute of the div.

someDiv.innerHTML = "";

Only as far as displaying the content goes, not the complete removal
of the division.
Nov 6 '08 #7
rf

"richard" <me****@newsguy.comwrote in message
news:9v********************************@4ax.com...
On Thu, 06 Nov 2008 09:21:04 GMT, "rf" <rf@invalid.comwrote:
>>
"richard" <me****@newsguy.comwrote in message
news:ch********************************@4ax.com. ..
>>On Thu, 06 Nov 2008 09:09:06 GMT, "rf" <rf@invalid.comwrote:
"richard" <me****@newsguy.comwrote in message
news:co********************************@4ax.co m...
>I have <div id=box1 style="display:block"as the initial setting.
I need to change the "display:block" to "display:none" then back to
"display:block" as a means of clearing anything that might be
displayed within the box1 division.

Changing the display property as above will *not* achieve "clearing
anything
that might be displayed".
As I have found out this is true.
So what will?

document.getElementById("box1").innerHTML = "";

but why? If you don't want stuff displayed in the div then don't put it in
there.

Now that, is the response I would expect from a 10 year old.
Well while we are here I might point out that your question, with no
explanation at all for the questions reason, and presuming a "solution" that
is so totally wrong that we all learnt it in HTML 101 stuff, is what I would
expect from a 10 year old.

Do you want help with this or not? If not then you are going about it
exactly the right way.
I am attempting to design a menu system that will that will have 3
levels of choices.
Bad idea. These things are not accessible, unless you take great pains to
make them so. How will I get to those lower level items if I don't have a
mouse? You are, of course, making provision for that, aren't you?
Yeah sure I could use those premade scripts that show your choices as
long as the cursor is over that item. But I need stability.
So use one of them and modify it to suit your needs? From your original "10
year old" question it might just be better though if you don't attempt to
modify it.
Item 1 has only one choice.
Items 2 and 3 will have two sublevels to choose from.
Item 4 will have one level.
All of which is contained within "box1".
Why. Why not give them each a different box. You are going about this
entirely the wrong way, but then again this is your usual modus operandi.

And how did you get the menu items in the div in the first place?
What you see displayed is the content of your first level item choice.
So why show the others?
Why fart about with changing the contents of one single div? Why not do it
like all the other dropdown menu scripts (and CSS alternatives) out there?
Use one div per dropdown. Then all you have to do is swich the display mode
to 'block' for the active one.
Of course, I could just as well write a seperate page for each choice
but that would mean keeping track of that many more pages.
What? Who said anything about pages? We are talking about divs here. If you
can't keep track of four (yes, I counted) divs then maybe writing web pages
is not what you should be doing. Driving trucks, perhaps?
Nov 6 '08 #8
richard meinte:
>someDiv.innerHTML = "";


Only as far as displaying the content goes, not the complete removal
of the division.
See the solution above or - perhaps more standards compliant - something
like:

someDiv.childNodes.length = 0;

or

while(someDiv.hasChildNodes()) {
someDiv.removeChild(someDiv.lastChild);
}

Anyway, you've been told before that this whole approach for your
drop-down menu is idiotic.

"Yeah sure I could use those premade scripts that show your choices as
long as the cursor is over that item. But I need stability."

LOL. So you are replacing the not-too-stable premade scripts, by your
own solution, without having the slightest clue of JS and DOM scripting.
Interesting.

(Does this make me a "ten-year-old"?)

Gregor
Nov 6 '08 #9

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

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
55
by: Ton den Hartog | last post by:
Stupid basic question but I find it horribly imposible to find the answer elsewhere... :-( I want to have a piece of text in my HTML page and want to be able to change it in a Javascript...
3
by: Craig | last post by:
Hi, What I'm trying (quite poorly) to do is make it so when a link is clicked the text inside a div or p changes. I've tried numerous things, most of which work in IE but none of which work in...
8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
4
by: David | last post by:
I attempted the following <div id="div" runat="server"> <tr><td></td></tr> <tr><td></td></tr> </div> This is to hide a group of rows depending on some business rules in my code behind.
3
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
2
by: Richard Maher | last post by:
Hi, I'm trying to use the Visibility Style attribute for a Div to effectively PopUp a lightweight window with some additional context-sensitive information, when a user mouses over a given...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.