faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 4 people (100%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

I selected some text in a text area. how can I know what they are?

Aug 18th, 2002 16:27
Petr Ton, peter yao,


For MSIE v.4+
<head>
<script>
function ViewSelected (from_obj, to_obj)
{
from_obj.focus ();
var w = self.document.selection.createRange ();
to_obj.value = r.text;
}
</script>
</head>
<body>
<textarea id = "forSELECT" cols = "30" rows = "10">some text some text 
some text...</textarea>
<p>
<input type = "button" value = "View selected" onclick = "ViewSelected 
(forSELECT, forVIEW);">
</p>
<p>Selected text:<br><textarea id = "forVIEW" cols = "30" rows 
= "10"></textarea>
</p>
</body>