Jump to content

How To Do Like This?


dollar

Recommended Posts

Put each item in an ordered list item.I have no idea what your code looks like, so I can only guess how to do it for you.What exactly are you trying to achieve? It may be better to do it with PHP, unless the list is updated after the page loads.Here's an example code, but I really need more information in order to do something more like what you really intend to do.

var kids = [  "a",  "b",  "c",  "d"];var list = document.createElement("ol");var item;for (var i=0; i<kids.length; i++) {  item = document.createElement("li");  item.innerHTML = kids[i];  list.appendChild(item);}document.body.appendChild(list);

Link to comment
Share on other sites

My friend had written names of kids in .txt file sent me.That .txt file contain names of all kids in a class. Like this :

a b c d e f g . . . . . z
I want to copy/paste contents in that .txt file into another notepad , write any code and make like this:
1. a2. b3. c4. d5. e6. f7. g......26. z
So is there any way to do that?Yeah I know we can do that manually or with simple HTML ordered list. But my problem is the list pretty big, so I need one short way..
Link to comment
Share on other sites

Or you could just use a normal text-editor's search and replace functions to take a list and reformat it as an array -- for example, find a paragraph break and replace it with some quote marks and a comma. If you plan it carefully, you can turn several hundred list items into an array in about a minute. I do that sort of thing often. You could even save the array definition as a separate javascript file and just add it to your document's head.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...