Current location: Hot Scripts Forums » General Web Coding » JavaScript » Editing text in Textarea html control


Editing text in Textarea html control

Reply
  #1 (permalink)  
Old 09-10-06, 05:26 AM
sudidelaravindra sudidelaravindra is offline
New Member
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post Editing text in Textarea html control

I have a small application which has Textarea control,textbox control,and a button control.I have some text in the Textarea control.when i select some part of the text in the Textarea control and pressed a button,that selected text along with the starting index and ending index should be displayed in the textbox.i have achieved of capturing the selected text into the textbox but i couldn't able to trace starting and ending index of selected text.Along with this requirement, i should get the selected text in bold style in the textarea control so that selected text could be differentiable.

Note: Need to use javascript.

can you plz help me out.....
Thanks
Reply With Quote
  #2 (permalink)  
Old 09-15-06, 10:17 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
If you have the selected text, you can do something like this:
Code:
startIndex=textArea.value.indexOf(selectedText)
endIndex=startIndex+selectedText.length
I just took a quick look at the sourcecode of this forum to see how they did it. And as I feared it's a fairly complex task to insert text around a selection. But the forum manages to do it both in IE and Mozilla based browsers.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
html tutoral thefrtman HTML/XHTML/XML 5 04-27-09 10:25 AM
Draggable Tables Ares JavaScript 10 08-03-06 06:55 AM
Need Your HelP! Loading Multiple External Text into Multiple Dynamic Text Fields Flash_Boi Flash & ActionScript 2 03-30-06 03:27 PM
Insert or Wrap HTML tags into a TextArea Industriality JavaScript 5 04-23-05 02:20 PM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM


All times are GMT -5. The time now is 11:16 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.