File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hiding/Showing div elements using Javascript

 
John Zwick
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are there double equals in your assignments ??



should be

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit is correct

You can make the code more compact:


Readable:


or

Harder to read, but more compact


Eric
 
John Zwick
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow you guys are awesome!

thanks a lot!
 
John Zwick
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64194
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not show server-side markup in an HTML forum. Expand the markup to its generated HTML.
 
John Zwick
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use onblur instead of onchange or call your function onload of the page.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic