dollar Posted March 26, 2009 Share Posted March 26, 2009 Let's say I've names of 26 kids. And I'm writing all names here :abcd...zSo, is there any way make them automatically start with numbers? Like this :1. a2. b3. c...26.z Link to comment Share on other sites More sharing options...
Ingolme Posted March 26, 2009 Share Posted March 26, 2009 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 More sharing options...
dollar Posted March 27, 2009 Author Share Posted March 27, 2009 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 . . . . . zI 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. zSo 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 More sharing options...
Ingolme Posted March 27, 2009 Share Posted March 27, 2009 Javascript can't write in files. You need a server-side language, such as PHP. Link to comment Share on other sites More sharing options...
jeffman Posted March 27, 2009 Share Posted March 27, 2009 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 More sharing options...
justsomeguy Posted March 27, 2009 Share Posted March 27, 2009 ConTEXT has support for macros, it's pretty easy to make some clever usage of CTRL and SHIFT plus the arrow keys to transform just about any data. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.