aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Supplying value to innerHTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Supplying value to innerHTML" Watch "Supplying value to innerHTML" New topic
Author

Supplying value to innerHTML

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi guys, I wanted my code to be neat. So instead of inlining HTML text string in one of my div's innerHTML, I want another div to be the value.

in javascipt:

targetDiv.innerHTML = anotherDiv;

targetDiv is like this...

in HTML:


but this is producing an error, 'content is undefined'. I'm doing this because I want to make some textboxes appear and disappear and shift table rows upward/downward whenever a condition is met(like a checkbox is pressed). Any ideas? Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Pavan Keely
Ranch Hand

Joined: Jun 30, 2006
Posts: 62
Timothy,

Use,



Pavan Keely<br /><a href="http://keelypavan.blogspot.com" target="_blank" rel="nofollow">http://keelypavan.blogspot.com</a>
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Pavan is correct. But your method isn't making things any more neat. It's just adding an extra div that you don't need.


GenRocket - A Test Data Generation Platform
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
So what could be a better solution then? If I just hide the div, the rows that it occupy is still visible and my layout is all broken. Any better solutions than the one I currently have in mind? Thanks!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well you are hiding it the wrong way.

document.getElementById("yourId").style.display="none";
document.getElementById("yourId").style.display="block";

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Supplying value to innerHTML
 
Similar Threads
Getting "not a multipart request" even though the image is being saved.
Problem setting TD tag innerHTML
Need Help with binding click events to table rows
Need help with Jquery
how to create a table through ajax dynamically