This is the code. you do not edit post.php and post.php at all. just copy the code to bb_code.php
changes :
1. exchange script code and html code for form tag should first come before prep_mode function.
2. some changes dealing with radio input.
<table border="0" cellpadding="0" cellspacing="4" width="100%">
<tr>
<td width="100%">
<//-------------------------------------------->
<//well we have some cool options here :) >
<//-------------------------------------------->
<select name="font" onChange="Pastebbcode('font', this.options[this.selectedIndex].value)">
<option value="-">Font</option>
<option value="Arial">Arial</option>
<option value="Courier New">Courier New</option>
<option value="Impact">Impact</option>
<option value="Tahoma">Tahoma</option>
<option value="Times New Roman">Times New Roman</option>
<option value="Trebuchet MS">Trebuchet MS</option>
<option value="Verdana">Verdana</option>
</select>
<select name="size" onChange="Pastebbcode('size', this.options[this.selectedIndex].value)">
<option value="-">Size</option>
<option value="1">Small</option>
<option value="2">Medium</option>
<option value="3">Large</option>
<option value="4">Largest</option>
</select>
<select name="color" onChange="Pastebbcode('color', this.options[this.selectedIndex].value)">
<option value="-"> Color </option>
<option style="color:blue" value="blue">Blue</option>
<option style="color:darkblue" value="darkblue">Dark Blue</option>
<option style="color:indigo" value="indigo">Indigo</option>
<option style="color:violet" value="violet">Violet</option>
<option style="color:white" value="white">White</option>
<option style="color:black" value="black">Black</option>
<option style="color:darkred" value="darkred">Dark Red</option>
<option style="color:red" value="red">Red</option>
<option style="color:orange" value="orange">Orange</option>
<option style="color:brown" value="brown">Brown</option>
<option style="color:yellow" value="yellow">Yellow</option>
<option style="color:green" value="green">Green</option>
</select>
</td>
</tr>
<tr>
<td>
<//-------------------------------------------->
<// if we need some bbcode buttons :) >
<//-------------------------------------------->
<input type="button" class="punbutton" value="B" name='B' style="font-weight:bold" onClick="Pastebbcode('b')">
<input type="button" class="punbutton" value="I" name='I' style="font-style:italic" onClick="Pastebbcode('i')">
<input type="button" class="punbutton" value="U" name='U' style="text-decoration:underline" onClick="Pastebbcode('u')">
<input type="button" class="punbutton" value="List" name='list' onClick="Pastebbcode('list')">
<input type="button" class="punbutton" value="Img" name='img' onClick="Pastebbcode('img')">
<input type="button" class="punbutton" value="http://" name='http://' onClick="Pastebbcode('url')">
<input type="button" class="punbutton" value="email" name='email' onClick="Pastebbcode('email')">
<input type="button" class="punbutton" value="quote" name='quote' onClick="Pastebbcode('quote')">
<input type="button" class="punbutton" value="code" name='code' onClick="Pastebbcode('code')">
<input type="button" class="punbutton" value="close all tags" name='close all tags' onClick="closeAllTags()">
</td>
</tr>
<//---------------------------------------------------->
<//but what if we need change radio button status :/ >
<//---------------------------------------------------->
<tr>
<td>
<small><input type="radio" name="mode" value="normal" onClick="changeMode('normal')"> Guided Mode <input type="radio" name="mode" value="advanced" onClick="changeMode('advanced')" checked> Normal Mode</small>
</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
/*
+--------------------------------------------------------------------------
| PunBB code buttons 1.0.1
| ========================================
| by Maciej Ziolkowski
| http://pubbmod.wz.cz/forum
| ========================================
| Time: Fri, 28 May 2004 13:08:30 GMT+1
| Email:
+---------------------------------------------------------------------------
*/
//--------------------------------------------
// Determine browser type and stuff.
//--------------------------------------------
var comp = navigator.userAgent.toLowerCase();
var vers = parseInt(navigator.appVersion);
var msie = ((comp.indexOf("msie") != -1) && (comp.indexOf("opera") == -1));
var nets = ((comp.indexOf('spoofer')==-1) && (comp.indexOf('compatible') == -1) && (comp.indexOf('opera')==-1) && (comp.indexOf('webtv')==-1) && (comp.indexOf('hotjava')==-1));
var moz = ((comp.indexOf("msie") == -1) && (comp.indexOf('mozilla')!=-1) && (comp.indexOf("opera") == -1));
var win = ((comp.indexOf("win")!=-1) || (comp.indexOf("16bit") != -1));
//--------------------------------------------
// Set up values
//--------------------------------------------
var b_prompt = "Please enter the text to be formatted in bold.";
var i_prompt = "Please enter the text to be formatted in italics";
var u_prompt = "Please enter the text to be underlined.";
var font_prompt = "Please enter the text to be formatted with the font tag.";
var size_prompt = "Please enter the text to be formatted with the size tag.";
var color_prompt = "Please enter the text to be formatted with the color tag.";
var align_prompt = "Please enter the text to be aligned.";
var quote_prompt = "Please enter the text to be quoted.";
var code_prompt = "Please enter the code to be treated as code and unformatted text.";
var myTags = new Array();
var buttonOver = "";
var normalmode = false;
//--------------------------------------------
// Set radio button status
//--------------------------------------------
prep_mode();
function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ");
for (i=0; i<thisCookie.length; i++) {
if (cookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].split("=")[1];
}
}
return "";
}
function prep_mode() {
expireDate = new Date;
expireDate.setMonth(expireDate.getMonth()+6);
theMode = cookieVal("cb_mode");
if ( theMode == "normal" ) {
document.getElementsByName("mode")[0].checked = true;
document.getElementsByName("mode")[1].checked = false;
normalmode = true;
} else {
document.getElementsByName("mode")[0].checked = false;
document.getElementsByName("mode")[1].checked = true;
normalmode = false;
theMode = "advanced";
}
document.cookie = "cb_mode="+theMode+"; path=/; expires=" + expireDate.toGMTString();
}
function changeMode(newMode) {
expireDate = new Date;
expireDate.setMonth(expireDate.getMonth()+6);
document.cookie = "cb_mode="+newMode+"; path=/; expires=" + expireDate.toGMTString();
if(newMode == "normal") {
normalmode = true;
} else {
normalmode = false;
}
}
//--------------------------------------------
// function Size
//--------------------------------------------
function Size(arrayName) {
for (i=0;i<arrayName.length;i++) {
if((arrayName[i] == "undefined") || (arrayName[i] == "") || (arrayName[i] == null)) {
return i;
}
}
return arrayName.length;
}
//--------------------------------------------
// function Push
//--------------------------------------------
function Push(arrayName, arrayValue) {
arraySize = Size(arrayName);
arrayName[arraySize] = arrayValue;
}
//--------------------------------------------
// function Pop
//--------------------------------------------
function Pop(arrayName) {
arrayMo = Size(arrayName);
arrayValue = arrayName[arrayMo - 1];
delete arrayName[arrayMo - 1];
return arrayValue;
}
//--------------------------------------------
// function inArray
//--------------------------------------------
function inArray(item, arrayName) {
for(i=0;i<arrayName.length;i++) {
if(arrayName[i] == item) {
return true;
}
}
return false;
}
//--------------------------------------------
// function pos
//--------------------------------------------
function Pos(item, arrayName) {
for(i=0;i<arrayName.length;i++) {
if(arrayName[i] == item) {
return i;
}
}
return -1;
}
//--------------------------------------------
// function list
//--------------------------------------------
function List(type) {
if(type) {
theList = "[list="+type+"]\n";
} else {
theList = "[list]\n";
}
promptRes = "1";
while((promptRes != "") && (promptRes != null)) {
promptRes = prompt("Enter a list item. Click cancel or leave blank to end the list.", "");
if((promptRes != "") && (promptRes != null)) {
theList = theList+"[*]"+promptRes+"\n";
}
}
theList = theList+"[/list]\n";
Pastecode(theList);
}
//--------------------------------------------
// function url
//--------------------------------------------
function Hyperlink() {
var url = prompt("Please enter the URL of the website.", "http://");
if(url) {
var urltitle = prompt("If you wish to, you may also insert a title to be shown instead of the URL.", "");
if(urltitle) {
Pastecode("[url="+url+"]"+urltitle+"[/url]");
} else {
Pastecode("[url]"+url+"[/url]");
}
} else {
// should we display errror or not? if you want remove this :)
alert("You must enter a URL and a title.");
// ------------------------------------------------------------
}
}
//--------------------------------------------
// function image
//--------------------------------------------
function Img() {
var image = prompt("Please enter the remote URL of the image.", "http://");
if(image) {
Pastecode("[img]"+image+"[/img]");
} else {
// should we display errror or not? if you want remove this :)
alert("You must enter a URL for the image.");
// ------------------------------------------------------------
}
}
//--------------------------------------------
// function email
//--------------------------------------------
function Email() {
var email = prompt("Please enter the email address.", "");
if(email) {
var emailtitle = prompt("If you wish to, you may also insert a title to be shown instead of the email address.", "My Email Address");
if(emailtitle) {
Pastecode("[email="+email+"]"+emailtitle+"[/email]");
} else {
Pastecode("[email]"+email+"[/email]");
}
} /* added by me */
else {
// should we display errror or not? if you want remove this :)
alert("You must enter a email address.");
// ------------------------------------------------------------
}
}
//--------------------------------------------
// function Paste bbcode
//--------------------------------------------
function Pastebbcode(myCode,selItem) {
if(myCode == "list") {
List(selItem);
} else if(myCode == "url") {
Hyperlink();
} else if(myCode == "img") {
Img();
} else if(myCode == "email") {
Email();
} else {
if(normalmode) {
var prompttext = eval(myCode + "_prompt");
if(selItem) {
if(selItem != "-") {
promptres = prompt(prompttext + "\n["+myCode+"="+selItem+"]xxx[/"+myCode+"]", "");
}
} else {
promptres = prompt(prompttext + "\n["+myCode+"]xxx[/"+myCode+"]", "");
}
if((promptres != null) && (promptres != "")) {
if(selItem) {
if(selItem != "-") {
Pastecode("["+myCode+"="+selItem+"]"+promptres+"[/"+myCode+"]");
}
} else {
Pastecode("["+myCode+"]"+promptres+"[/"+myCode+"]");
}
}
} else {
var thingA = myCode+"_"+selItem;
args = thingA.split("_");
lastIndex = 0;
alreadyopen = false;
for(i=0;i<myTags.length;i++) {
theTag = myTags[i];
if(theTag) {
args2 = theTag.split("_");
if(args2[0] == args[0]) {
alreadyopen = true;
lastIndex = i;
}
}
}
if(alreadyopen) {
while(myTags[lastIndex]) {
tagRemove = Pop(myTags);
thingB = tagRemove.split("_");
Pastecode("[/"+thingB[0]+"]", "", false);
// unclick it
element = eval("document.images['"+tagRemove+"']");
if(element && !element.disabled && element.nodeName == "IMG") {
if(Over == tagRemove) {
}
}
if(thingA == tagRemove) {
noInsert = true;
}
}
}
if(selItem && selItem != "-" && !noInsert) {
isClosed = Pastecode("["+myCode+"="+selItem+"]", "[/"+myCode+"]", true);
if(!isClosed) {
Push(myTags, myCode+"_"+selItem);
} else {
element = eval("document.images['"+myCode+"']");
if(element && !element.disabled && element.nodeName == "IMG") {
element.className = "toolbar";
}
}
}
else if(!selItem && !alreadyopen) {
isClosed = Pastecode("["+myCode+"]", "[/"+myCode+"]", true);
if(!isClosed) {
Push(myTags, myCode);
} else {
element = eval("document.images['"+myCode+"']");
if(element && !element.disabled && element.nodeName == "IMG") {
element.className = "toolbar";
}
}
}
var alreadyopen = false;
var noInsert = false;
}
}
setFocus(document.all.req_message);
}
//--------------------------------------------
// function close all Tags
//--------------------------------------------
function closeAllTags() {
if(myTags[0]) {
while(myTags[0]) {
tagRemove = Pop(myTags);
args = tagRemove.split("_");
isClosed = Pastecode("[/"+args[0]+"]", "", false, true);
element = eval("document.images['"+tagRemove+"']");
if(element && !element.disabled && element.nodeName == "IMG") {
element.className = "toolbar_normal";
}
}
}
myTags = new Array();
setFocus(document.all.req_message);
}
//--------------------------------------------
// function Pastecode
//--------------------------------------------
function Pastecode(myCode, myClose, singleTag, ignoreSel) {
isClosed = true;
if(ignoreSel != true) {
ignoreSel = false;
}
var messageBox = document.getElementById("req_message"); ;
if(msie && win && (vers >= 4)) {
setFocus(messageBox);
var seltext = document.selection;
var range = seltext.createRange();
if(ignoreSel != false) {
range.collapse;
}
if(((seltext.type == "Text" || seltext.type == "None") && range != null) && ignoreSel != true) {
if(myClose && range.text.length > 0) {
myCode = myCode+range.text+myClose;
} else {
if(singleTag) {
isClosed = false;
}
}
range.text = myCode;
} else {
messageBox.value += myCode;
}
}
else if(moz) {
var select_start = messageBox.selectionStart;
var select_end = messageBox.selectionEnd;
if(select_end <= 2) {
select_end = messageBox.textLength;
}
var start = (messageBox.value).substring(0, select_start);
var middle = (messageBox.value).substring(select_start, select_end);
var end = (messageBox.value).substring(select_end, messageBox.textLength);
if((messageBox.selectionEnd - messageBox.selectionStart > 0) && ignoreSel != true) {
middle = myCode+middle+myClose;
} else {
if(singleTag) {
isClosed = false;
}
middle = myCode+middle;
}
messageBox.value = start+middle+end;
}
else {
messageBox.value += myCode;
if(singleTag) {
isClosed = false;
}
}
setFocus(messageBox);
return isClosed;
}
//--------------------------------------------
// function setFocus
//--------------------------------------------
function setFocus(formElement) {
formElement.focus();
}
//--------------------------------------------
// function addsmilies
//--------------------------------------------
function smilie(addemot)
{
Pastecode(" " + addemot + " ", "", false);
}
//--------------------------------------------
// Script End
//--------------------------------------------
</script>