Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 Building Microservices this week in the Design 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!
I agree. Here's the link:
subject: document.write question
jQuery in Action, 3rd edition