File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60794
    
  65

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: 60794
    
  65

Learning what to avoid is as important as learning what to do.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help with displaying data properly
 
Similar Threads
document.forms[0].submit(); throws Invalid Argument in IE
change CSS rules dynamic with JavaScript
JavaScript Newbie Simple Problem
Method not defined in Firefox 3.0.7 working fine in Firefox 3.0.3
java Script Program