homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

highlighted text copied into a form textarea with the click of a butto

10+ Year Member

Msg#: 5365 posted 8:04 pm on May 2, 2006 (gmt 0)

anyone know how to do it?
can someone give me an example?

I also will need to fetch message id's or userid's along with the highlighted text

thx :)



WebmasterWorld Senior Member 10+ Year Member

Msg#: 5365 posted 3:21 am on May 4, 2006 (gmt 0)

As far as I know, selected text to form only works with IE. Here's an example that shows how it works.

<script type="text/javascript">
function insertText() {
if (document.selection && document.selection.createRange) {
var str = document.selection.createRange().text;
document.selection.createRange().text = str;
<p>Select this text and click this <a href="javascript:insertText()">link</a>.</p>
<form><textarea cols="50" rows=
"1" name="body"></textarea></form>

I wrote a really cool selected text to form script, complete with a custom context menu, for use in the forum listed in the site in my profile. It's a good example of how handy this feature can be.

I wish Opera and FireFox would support selected text to form.


10+ Year Member

Msg#: 5365 posted 5:07 am on May 4, 2006 (gmt 0)

ow but Firefox does support it, I know a site which uses it and I only use Firefox

I looked at the Javascript, but its way to complicated for me to understand hehehe

thx for the help, I'll try it out

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved