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

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-04-2007, 03:06 AM   PM User | #1
ojoonline
New Coder

 
Join Date: Feb 2003
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
ojoonline is an unknown quantity at this point
Insert into a textarea

Hi,

I have this code that lets me insert text into a textarea from a button. Currently, it inserts the text at the end of what is in the textarea. Is there a way to make it insert where the cursor is instead?

<script>
function inser1() {
document.getElementById('ip').value+= '<firstName>'
}
</script>

thanks,

jo
ojoonline is offline   Reply With Quote
Old 01-04-2007, 11:32 PM   PM User | #2
1212jtraceur
Regular Coder

 
Join Date: Oct 2006
Posts: 206
Thanks: 1
Thanked 0 Times in 0 Posts
1212jtraceur is an unknown quantity at this point
Not that I know of, without some very complex scripting to guess the character under the cursor...Maybe, however, there is a simpler way.
1212jtraceur is offline   Reply With Quote
Old 01-05-2007, 04:34 AM   PM User | #3
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 1,096
Thanks: 1
Thanked 188 Times in 185 Posts
jmrker is on a distinguished road
I summitted a solution to another forum recently and it worked for them.

Try: http://www.webdeveloper.com/forum/s...ad.php?t=110464

Or look into:
http://www.sitepoint.com/forums/showthread.php?t=296023
How can I manipulate the selection and the caret in an input type="text" element in Mozilla browsers and IE/Win?
http://www.alexking.org/blog/2003/0...ing-javascript/
http://www.massless.org/mozedit/
http://parentnode.org/javascript/wo...ursor-position/
jmrker is online now   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 04:25 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.