User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Jun 2007
Posts: 71
Reputation: Pro2000 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pro2000's Avatar
Pro2000 Pro2000 is offline Offline
Junior Poster in Training

Add a tag(Java)

  #1  
Jul 14th, 2007
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 71
Reputation: Pro2000 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pro2000's Avatar
Pro2000 Pro2000 is offline Offline
Junior Poster in Training

Re: Add a tag(Java)

  #2  
Jul 14th, 2007
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:01 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC