Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Supplying value to innerHTML

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Pavan Keely
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timothy,

Use,

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you are hiding it the wrong way.

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

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic