Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mySQL Recipe Database
#21
Quote:with javascript:
myTable = document.getElementById("tableid");
newRow = myTable.insertRow();
newCell = newRow.insertCell();
newCell.innerHTML = "blahblahblah";

This isn't exactly the "fastest" method, but it's the best method if you're looking for compact code and/or easy-to-code code.

Oh wow... this definitely looks like the most elegant thing I've seen so far... I'll definitely experiment with this. Thanks.

I was looking at generating a bunch of DIVs from php and then show/hiding them with javascript. Would have been ugly as hell... and a very bloated file to be downloaded by anyone submitting something.

EDIT :: To anyone facing this, there's a perfect example here: here. The 'innertext' method doesn't work under FireFox, but if you change it to innerHTML, it DOES work. Thanks so much again, it always helps to know what keywords to search for.

--

EDIT 2 :: Removed link to a page I'm now working on.
Reply
#22
If you want an mozilla-friendly equivalent to 'innerText', then use the proper DOM method of inserting a text node:

container.appendChild(document.createTextNode("some text"));

where container is where you want to insert text into. If you want to insert in between elements:

document.insertBefore(newElement, someExistingElement);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)