473,411 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

List of numbers 1-10 not appearing.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Hello, HTML!</title>
  5.     <script> 
  6.          function countToTen() {
  7.             var count = o ;
  8.             while (count < 10) {
  9.                 count ++ ;
  10.                 document.getElementById("theCount").innerHTML += count + "<br>";
  11.             }
  12.         }
  13.         Code-Line Before Listing Code </script>
  14.         </head>
  15.         <body onload="countToTen();">
  16.             <h1>Let's Count to 10 with Javascript!</h1>
  17.             <p id="theCount"></p>
  18.         </body>
  19.         </html>
On the browser only 'Lat's count to ten with JavaScript!' appears but the list of numbers does not.
Please help. Regards
Jan 9 '19 #1

✓ answered by gits

why do you initialize the variable count with another undefined variable o?

and that Code-Line Before Listing Code in the script section breaks the code as well if its really there and not just a copy and paste error.

3 1776
gits
5,390 Expert Mod 4TB
why do you initialize the variable count with another undefined variable o?

and that Code-Line Before Listing Code in the script section breaks the code as well if its really there and not just a copy and paste error.
Jan 9 '19 #2
Hi! Thanks for your support Gits. I am only pasting a code as advised by a book I am learning from. Have checked the code for every comma etc and it is the absolute copy as printed in the book. However am not getting the numbers printed. Am using sublimeteaxt editor, what should the code be for listing? shouldn't <Li> command be used somewhere? Do continue your support.Appreciate much.
Jan 9 '19 #3
gits
5,390 Expert Mod 4TB
well i gave you the answer already: remove that mentioned text in the script section and initialize the variable count correctly - then the code will run and do what it should.

PS: the code simply adds the count as plain text to a <p>-element which probably is enough for the sake of 'outputting' something - of course you could create new elements and build up a ordered or unordered list or whatever you want to do with the result. Javascript gives you the possibility to manipulate the DOM of a html document in nearly any way you want.
Jan 9 '19 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jenn L | last post by:
I have a database that is pre-populated with sequential part numbers. As people reserve the parts I update a flag to show the # is no longer available. Now they want the ability to take out a...
4
by: Ken Innes | last post by:
Apparently, surrounding an ordered list by a font command is illegal. So how do I specify the font style and size for the list elements? Putting font tags on each list item works, except that the...
6
by: Christian Roth | last post by:
Hello, how do I offset the numbering of a list in XHTML Strict (+CSS) in current browsers? What I want is something like: 5. Item a 6. Item b 7. Item c
6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesnąt matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
13
by: deko | last post by:
http://www.liarsscourge.com/ewpi.html The list numbers should be formatted as <h3>, but other text within the <li> should be normal text. <ol> <li> <h3 id="d2">Download latest WordPress...
3
by: Kasrav | last post by:
hey guys it me again i got stuck in the middle of this program. The program starts with a list declaration of these numbers , i have to make sure the program outputs the following 1 The number...
6
by: Patrick C | last post by:
lets say i have this list: numbers = and i want my script to tell me that the highest number in the list is '20' how can i do that? thnx
2
by: benefits2072 | last post by:
what if you wanted to find a number in the middle of that list: how would you go about that?
6
by: aine_canby | last post by:
hi, I have the following list - how do I sort it like this -
1
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I need to know how / if it's possible to apply a background color to a ordered list item's numbers, and not the content itself. I've tried: ol { background-color: #FFFF00; } But that...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.