By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,363 Members | 2,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,363 IT Pros & Developers. It's quick & easy.

changing specific <div> status

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.