View Single Post
Old 12-30-2008, 04:00 PM   #6 (permalink)
Costin Trifan
Meeow!
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 3,235
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest order
^^ I've put that code only for fun, it's not final or anything (just the result of playing around with js).

About your request:

#1. Download the code for the texteditor from here: http://corpocrat.com/2008/12/18/free...a-html-editor/

#2. Open the ed.js file and paste the following code at the end of the file:
Code:
function doList() { // Check what type of list has been selected: var list = prompt("Select your list type: ", "ul"); if (list) { if (list.toLowerCase() == 'ul') { doAddTags('<ul>', ''); while(listitem = prompt('Enter your text', '')) { doAddTags('<li>'+listitem, '</li>'); } doAddTags('', '</ul>'); } else if (list.toLowerCase() == 'ol') { doAddTags('<ol>', ''); while(listitem = prompt('Enter your text', '')) { doAddTags('<li>'+listitem, '</li>'); } doAddTags('', '</ol>'); } else { return null; } } }
#3. In the same document, right at the beginning, you'll see a function called init and some lines starting with document.write. There paste this line of code:
Code:
document.write("<img class=\"button\" src=\"editor/images/link.gif\" name=\"btnList\" onClick=\"doList()\">");
and that's it.

If you'll use the exact code I posted here, you'll notice that your list button will have the same image as the link button. It will act the same way as the one of this editor (prompt you for each list item).

hope this helps
__________________
...to be continued
Costin Trifan is offline   Reply With Quote