•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,000 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,463 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1062 | Replies: 1 | Solved
![]() |
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.
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
<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
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- tag system (Database Design)
- How to pass a server side value to an attribute of a custom jsp tag (JSP)
- problem with java in fedora4 (*nix Software)
- java is supposed to be secure? (Java)
- about java servlets (Java)
- Java DSW algorithm Coding (Java)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Why the following does not work in Firefox
- Next Thread: Internet Explorer accessing form elements


Linear Mode