View Full Version : Need to modify boldText() script for multiple textfields

12-09-2006, 11:33 PM
Hey all,
I've got this script:

function boldText(textAreaId) {
var str = document.selection.createRange().text;
var sel = document.selection.createRange();
sel.text = "<b>" + str + "</b>";

It's works just fine for adding bold text to one <textarea> on a page. However, I need it to work for multiple textareas with multiple instances of a text-formatting toolbar that are being populated by a PHP for loop. As you can see, the script needs to refer to an id of "myTextarea". It won't work if I change the reference to "myTextarea" to the more generic textAreaId.

Any thoughts?