This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes document.write question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "document.write question" Watch "document.write question" New topic

document.write question

Harsha Jay
Ranch Hand

Joined: Jul 23, 2001
Posts: 177
I have a need to show the string output (return from javascript function )to presentation JSP. If I use document.write() the result is displayed in the entire page, How can I show the JS return string in a <td></td> only or a <li></li> element only. Is this possible?
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You can not use document.write after the page load. The best bet is to give the location you want the data to appear an id. Reference than id and set the DOM [createElement/createTextNode] or innerHTML with the new data.

Harsha Jay
Ranch Hand

Joined: Jul 23, 2001
Posts: 177
great Thanks, I am giving it a shot right now!
It is sorta covered in the JavaRanch Style Guide.
subject: document.write question
It's not a secret anymore!