Hello everybody.
I've tried the following code in the head:

<script language="JavaScript">
var TxtArea = 0;
function insert_bui( t ){
        if( !TxtArea        ) return;
        tx = document.selection.createRange( );
        switch( t ){
        case "B":
                tx.text = "-b-" + tx.text + "-/b-" ;
        case "I":
                tx.text = "-i-" + tx.text + "-/i-";
        case "U":
                tx.text = "-u-" + tx.text + "-/u-";
        document.selection.empty( );
        TxtArea = 0;

And I put the following code in the body:

<form name="TFrm" action="Send.php">
<input type="button" value="B" onclick="TFrm.TxtA.focus(); insert_bui('B');">
<input type="button" value="I" onclick="TFrm.TxtA.focus(); insert_bui('I');">
<input type="button" value="U" onclick="TFrm.TxtA.focus(); insert_bui('U');">
<input type="text" name="TxtA">
<input type="submit" value="Submit">

This code should enclose the selected characters in the TxtA field with the tags I specified in the function.
However, when I click on any button, it adds nothing!
Any help would be appreciated.

I think this code is well-written and has no errors.. What's the browser you're running your code on?

commented: I agree :( +3

I'm executing my code on Firefox..