Forum Moderators: open
Ok i have some JS i need to use in my PHP file to insert BBcode into a text area but it sems no matter what i try my JS wont work inside PHP it works in a regulair HTML file...
Any help is appretiated.
Below is my JS
function addText(Text)
{
var obj = document.send.message;
obj.focus();
if (document.selection && document.selection.createRange) // Internet Explorer
{
sel = document.selection.createRange();
if (sel.parentElement() == obj) sel.text = Text;
} else if (obj != "undefined") // Firefox
{
var longueur = parseInt(obj.textLength);
var selStart = obj.selectionStart;
var selEnd = obj.selectionEnd;
obj.value = obj.value.substring(0,selStart) + Text + obj.value.substring(selEnd,longueur);
}
else obj.value += Text;
obj.focus();
}
function addTags(Tag, fTag)
{
var obj = document.send.message;
obj.focus();
if (document.selection && document.selection.createRange) // Internet Explorer
{
sel = document.selection.createRange();
if (sel.parentElement() == obj) sel.text = Tag + sel.text + fTag;
}
else if (obj != "undefined") // Firefox
{
var longueur = parseInt(obj.textLength);
var selStart = obj.selectionStart;
var selEnd = obj.selectionEnd;
obj.value = obj.value.substring(0,selStart) + Tag + obj.value.substring(selStart,selEnd) + fTag + obj.value.substring(selEnd,longueur);
}
else obj.value += Tag + fTag;
obj.focus();
}
Below is what im using to input the BB tags into the textarea
<a title="Bold : [B ][/B ]" onmousedown="addTags(\'[B ]\',\'[/B ]\')" style="background-color:#F7F7F7; font-size:10pt; border: outset white 1px;"> <b>B</b> </a> Many thanks rick