Zelaron Gaming Forum

Zelaron Gaming Forum (http://zelaron.com/forum/index.php)
-   Tech Help (http://zelaron.com/forum/forumdisplay.php?f=329)
-   -   Anyone skilled enough to deal with this javascript inquiry? (http://zelaron.com/forum/showthread.php?t=46506)

Goodlookinguy 2008-08-15 05:43 AM

Anyone skilled enough to deal with this javascript inquiry?
 
This is rather hard for me to figure out how to express, so I'm going to write out part of this.

I want to make it so when I highlight text between an area in a <textarea> box, and click a button, that the highlighted words will be wrapped with words, like the vB BB Codes.

I've yet to become really experienced with JavaScript, and nothing I've tried works at all. That includes that nothing appears.

Lenny 2008-08-15 08:34 AM

You need to make a variable which is the selection, and then set the variable to be itself and the tags. This might help:

theSelection = document.selection.createRange().text;
document.selection.createRange().text = "*" + theSelection + "*";


Obviously you replace the stars with the tag you want. Don't know if it works in anything other than IE, though, and I haven't a clue where it would go. Have fun with it.


All times are GMT -6. The time now is 07:13 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.