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?

Thanks.

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*" ;
                break;
        case "I":
                tx.text = "*I*" + tx.text + "*/I*";
                break;
        case "U":
                tx.text = "*U* " + tx.text + "*/U*";
                break;
        }
        document.selection.empty( );
        TxtArea = 0;
}
</script>

Then put 3 buttons write in each:

onclick="insert_bui(****)

replace the **** by the cases.

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

onselect="TxtArea=1"

It's Easy Just think.... End

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.