Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection in TextArea 1

Status
Not open for further replies.

dizi

Programmer
Apr 3, 2002
4
0
0
US
How do i select a portion of text in a textarea?

thanks.
 
Try this example - works only in IE5 and above:
Name of methods are case sensitive.
Check MSDN for additional info.

<html>
<head>
<title> Tetxarea select </title>
<SCRIPT LANGUAGE=&quot;JScript&quot;>
function sel() {
var rng = document.sForm.sArea.createTextRange();
if (rng!=null) {
b = rng.findText(&quot;me&quot;) //returns true or false
if (b) {
rng.select()
}
}
}
</SCRIPT>
</head>
<body onLoad=&quot;sel()&quot;>
<h2>Text</h2>
<form name=&quot;sForm&quot;>
<textarea name=&quot;sArea&quot;>Test me here</textarea>
</form>
</body>
</html>
 
Excellent! Thanks alot.
 
hi dianal,

this is what i exactly wanted. Perfect !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top