• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Help with displaying data properly

 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see...

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

Thanks again Bear!
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Learning what to avoid is as important as learning what to do.
 
Fire me boy! Cool, soothing, shameless self promotion:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic