C
cyber0ne
I have a textarea for users to post stuff on a website, but right now
it's just straight text and they have to add their own HTML tags for
formatting. This usually isn't a problem except for carriage returns.
Not being a Javascript guru by any means, I was looking up how to
detect the keypress event, check to see if it's a carriage return
(keycode 13, right?) and insert an HTML line break into the textarea.
It all looks good except for one thing, I can only append the HTML to
the end of the textarea. What if the user is going back and re-editing
text? Any carriage returns in the middle of the textarea would result
in an HTML line break at the end of the textarea.
So, is there a way to insert text at the cursor position when a
specific keyevent is detected? Does anyone have any example scripts
that do this? Ideally I'd like it to be as cross-platform as possible,
since I have about a 65:30:5::IE:Firefox:Other ratio of browsers that
hit the site.
Regards,
David P. Donahue
(e-mail address removed)
it's just straight text and they have to add their own HTML tags for
formatting. This usually isn't a problem except for carriage returns.
Not being a Javascript guru by any means, I was looking up how to
detect the keypress event, check to see if it's a carriage return
(keycode 13, right?) and insert an HTML line break into the textarea.
It all looks good except for one thing, I can only append the HTML to
the end of the textarea. What if the user is going back and re-editing
text? Any carriage returns in the middle of the textarea would result
in an HTML line break at the end of the textarea.
So, is there a way to insert text at the cursor position when a
specific keyevent is detected? Does anyone have any example scripts
that do this? Ideally I'd like it to be as cross-platform as possible,
since I have about a 65:30:5::IE:Firefox:Other ratio of browsers that
hit the site.
Regards,
David P. Donahue
(e-mail address removed)