Hello there,

I designed 3 buttons and a form contains a Text Input, I want to make those 3 buttons add tags inside the Text Input,Explain:
Example: I am a user, I wrote in that Input a text,the text is:
"Hello How are you, bla bla bla..." I want to select the "How" word and click on some button,When I click on that button the button will add "B" before the text and "/B" after the text, How can I do it?


Come on guys! I have the answer this is the code:

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

Then put 3 buttons write in each:


replace the **** by the cases.

then put a text input and write in it this code:


It's Easy Just think.... End

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.