To integrate with your BBCode panel. Array the items.
<?php
$arr = array("B","I","U","S","Center","Scroll","URL");
foreach ($arr as $tx) {
echo "<input type=button value=".$tx." onClick=javascript:addBB('".strtolower($tx)."');>";
}
?>
then here's the function for the chat.js
function addBB(code) {
var el = document.getElementById("getText");
if (el.value.substring(el.selectionStart,el.selectionEnd)) {
//Selection found, add tags around it
el.value = el.value.substring(0,el.selectionStart) + "[" + code + "]" + el.value.substring(el.selectionStart,el.selectionEnd) + "[/" + code + "]" + el.value.substring(el.selectionEnd);
}
else {
//No selection, insert at cursor point
el.value = el.value.substring(0,el.selectionStart) + "[" + code + "][/" + code + "]" + el.value.substring(el.selectionStart);
}
}