View Full Version : forum elements
james438
08-28-2007, 04:02 AM
I am looking for a JavaScript code that will allow me to prepend and append highlighted text in a form with HTML tags.
I asked that same question -- twice -- and got no answer. . . *sigh* But I found a start for you (only works in IE; I know, I know, thats really lame, but hey, it's a start.):
function PlaceTag(tag){
var selectedText = document.selection.createRange().text;
if (selectedText != "") {
var newText = "(" + tag + "]" + selectedText + "[" + tag + ")";
document.selection.createRange().text = newText;
} else {
input = document.getElementById("input");
input.value = input.value + "("+tag+"]["+tag+")";
}
}
james438
08-29-2007, 02:07 PM
It is a place to start, thanks :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.