Hi there
Im trying to figure out on how to add bbcode to an textarea when i click it
currently i use this
print "<textarea name='textarea' rows='5' cols='40'></textarea><br>";
print "<a onClick=\"addBBcode('[b][/b]')\"><b>Bold text</b></a> | ";
print "<a onClick=\"addBBcode('[i][/i]')\"><i>Italic text</i></a> | ";
print "<a onClick=\"addBBcode('[u][/u]')\"><u>Underline text</u></a> | ";
and this
<script language="javascript">
function addBBcode(textToAdd) {
document.form.textarea.value += textToAdd;
document.form.textarea.focus();
}
</script>
Its freakin basic and doesnt really support more than one textfield (ie. when there is 2 textarea's i want the bbcode to be added in the currently focussed field (the one with the cursor atm.)
Though my code does not support that
I cant find any good javascript reference so maybe some of you can help me out
also im total noob at javascript... so its hard figuring this one out
thanks in advance!