...

View Full Version : Insert into a textarea



ojoonline
01-04-2007, 04:06 AM
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

1212jtraceur
01-05-2007, 12:32 AM
Not that I know of, without some very complex scripting to guess the character under the cursor...Maybe, however, there is a simpler way.

jmrker
01-05-2007, 05:34 AM
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/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum