wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Help with displaying data properly 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 "Help with displaying data properly" Watch "Help with displaying data properly" New topic
Author

Help with displaying data properly

Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Take it easy on me, complete JavaScript newb

Here is my simple code (CSS added into head for readability):



The user enters a number in a box and presses "Count" and the number is printed on the screen starting with 1, 2, 3, ... up to the users number. My question is that when this runs it does it on a fresh white screen with everything else gone. How do I go about having the output "1, 2, 3, etc" as part of the page itself. How can I not only add it into the page but put it into it's own div or class so that I can control how the output will look?

Thank you in advance!


SCJA
~Currently preparing for SCJP6
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61220
    
  66

document.write() should be avoided like the plague. It's only useful during the initial run of displaying the page, and even then there are better ways to do things. Used after the page is initially displayed, it replaces the page with whatever you are writing, as you have seen. Pretend it does not exist.

Rather, investigate DOM manipulation and the use of the innerHTML property.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
I see...

Well, always good to know you've learned a bunch of useless commands

Thanks again Bear!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61220
    
  66

Learning what to avoid is as important as learning what to do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with displaying data properly