| Author |
Hiding/Showing div elements using Javascript
|
John Zwick
Ranch Hand
Joined: Mar 02, 2009
Posts: 34
|
|
Can anyone explain why the following does not work?
However, this code works?
I dont understand why the second set of code works but the first doesnt.
Can someone please explain?
thanks!
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Why are there double equals in your assignments ??
should be
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Ankit is correct
You can make the code more compact:
Readable:
or
Harder to read, but more compact
Eric
|
 |
John Zwick
Ranch Hand
Joined: Mar 02, 2009
Posts: 34
|
|
wow you guys are awesome!
thanks a lot!
|
 |
John Zwick
Ranch Hand
Joined: Mar 02, 2009
Posts: 34
|
|
I have another question related to this:
The javascript is triggered by a dropdown list onchange event like so:
However this becomes a problem if the default selection of the dropdown is something else like "insert" or "message". Since there is no onchange event to trigger the javascript function, the appropriate div elements are not shown. How do I check for this when the page loads? Will have have to create another javascript function to check what the current value of the dropdown list is and show the appropriate div elements?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
|
Please do not show server-side markup in an HTML forum. Expand the markup to its generated HTML.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
John Zwick
Ranch Hand
Joined: Mar 02, 2009
Posts: 34
|
|
Bear Bibeault wrote:Please do not show server-side markup in an HTML forum. Expand the markup to its generated HTML.
oops, my bad
Here is the generated HTML:
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
use onblur instead of onchange or call your function onload of the page.
Eric
|
 |
 |
|
|
subject: Hiding/Showing div elements using Javascript
|
|
|