Computer problems,Computer help
*AX SOFT>>>Programming & Design

JavaScript Help!?


I have a homework assignment that is asking me to "Add a script to a website that writes a numbered list... Use JavaScript to write the appropriate <ol> and <li> tags and their content.

I know how to do this in HTML, but have searched everywhere cannot figure it out in JavaScript.

Any help would be much appreciated.

ok, so here's an exampls of an ordered list in html:
<ol>
<li>Coffee</li>
<li>Tea</li>
</ol>

and here is how one might print that same list in javascript:
document.write("<ol><li>Coffee</li><li...
idk why yahoo answers cuts this off! but it's the same text in the document write function.
does this help, it's been a while since i've done any javascript and i don't know the specifics of the assignment.

Avoid document.write(), when possible - it can be destructive of other page elements, unless properly encapsulated.

<head>
<!--
No matter which you select
as "best answer" - pick one.
-->
<script>
var list = [
"list item 1",
"list item 2",
"list item 3",
"list item 4",
"list item 5"
]

function doList() {
var d = document;
var ol = d.createElement('OL');
var last = list.length;
var li = '';
for (var i = 0; i < last; i++) {
li += '<li>' + list[i] + '</li>';
}
ol.innerHTML = li;
d.body.appendChild(ol);
}

window.onload = doList;
</script>
</head>
<body>
</body>
</html>

<html>

I think it goes something like this:

<html>
<head><title>Test</title></head>
<body>
<script type="text/javascript">
var values = new Array("First","Second","Third","Fourth")...
function list(values) {
聽聽document.write("<h1>Generated by JavaScript</h1>");
聽聽document.write("<ul>");
聽聽for (item in values) {
聽聽聽聽document.write("<li>" + values[item] + "</li>");
聽聽}
聽聽document.write("</ul>");
}

list(values);
</script>
</body>
</html>

If you are still stuck with your homework, may be you can contact a homework helper at website like http://homeworkhelp.co.in/ .

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • How can I make my own encryption software?

    If you have Qbasic, you already have a free program that will allow you to make your own encryption. It won't be fast or anything, but it can do it. I would suggest you learn C since that is t...

  • What do you make of Muslims4Jesus website?

    You can find out step by step guide on how to create a website at ...

  • BAT file help!?

    I LOVE bat files. Okay this is how I would do it. Put the shortcut to the game in your C:\WINDOWS\system32 folder. Put the song in your C:\WINDOWS\system32 folder so now you have ( le...

  • Css alignment question?

    Hard to say with certainty what the "best" approach would be without a deep understanding of the parent/child context, but you can shift the div "upward" by using a negative mar...

  • What does this c code output? Really simple and Easy!?

    offhand, I believe its.. 9 2 1 27 not sure if i'm right though edit: I just ran it, I'm right, that is what it is. But if you're in a programing class, this is something you...

  • What programming language should I start learning as the first language?

    I would suggest C, then C++ as well as the Linux operating system. A lot of the security software was written for and in Linux or Unix. Not surprising, the majority of it is also written in C or...

  • Backup file location?

    Removeable media. DVD, CD-ROM or CD-WORM, tape, USB external hard drive... Anything that you can take away from the computer physically, put it in another room, or let a trusted relative keep it....

  • What program can i use to make a timeline?

    u can use Microsoft word and draw a line. then use little lines as the lines. then put a text box at every line.

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster