Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-10-2002, 02:35 PM   PM User | #1
glb
New to the CF scene

 
Join Date: Jul 2002
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
glb is an unknown quantity at this point
how to insert text in a text area depending on the cursor position

I hope the subject is clear...
I would like to insert a selected item value of a combo at the position where the focus is in a textarea (so, not at the end) that already contains text.
glb is offline   Reply With Quote
Old 07-10-2002, 05:48 PM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Say you have insertValue equal to the string you want to insert.

In recent builds of Mozilla, you can go like:

refToTextArea.value = refToTextArea.value.substr(0, refToTextArea.selectionStart) + insertValue + refToTextArea.value.substring(refToTextArea.selectionStart);

Not sure exactly the methods to do it in IE, but it involves the TextRange() object... somebody else here should know how.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:33 PM.


Advertisement
Log in to turn off these ads.