Welcome to WebmasterWorld Guest from 54.196.144.242

Forum Moderators: open

Message Too Old, No Replies

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

     
8:04 pm on May 2, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 8, 2004
posts:500
votes: 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 :)

3:21 am on May 4, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 27, 2001
posts:1472
votes: 0


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

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

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.

5:07 am on May 4, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 8, 2004
posts:500
votes: 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