Hi,
I have the following javascript in the header of my page to allow me to add text to a text area on a button click:
[CODE]function insert(el,ins) {
if (el.setSelectionRange){
el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length);
}
else if (document.selection && document.selection.createRange) {
el.focus();
var range = document.selection.createRange();
range.text = ins + range.text;
}
}
And then I have some buttons on my page like this:
<input name=”bold” type=”button” id=”bold” onclick=”insert(this.form.replytext,'[ b][ /b]’)” value=”Bold”>
<input name=”italic” type=”button” id=”italic” onclick=”insert(this.form.replytext,'[ i][ /i]’)” value=”Italic”>
The first button works perfectly, however the second button (italic) and any additional buttons add their code, however they always also insert the [ b][ /b] code after it.
So for example, clicking the italic button would insert [ i][ /i][ b][ /b] into the text area. (I have added spaces so that the code shows up in this message).
Can anyone help?
Thanks