Select / highlight textarea box javascript code
Highlight Me.
Script Description:
Select all TextArea of Text input box for subsequent copy-and-paste.
Cut-and-paste code inside BODY section:
i.e., between <BODY> and </BODY> tags of your HTML file
<form name="MyTextBoxForm">
<input type=button value="Highlight text below" onClick="javascript:this.form.MyTextBox.focus();this.form.MyTextBox.select();" name="button">
<br>
<textarea name="MyTextBox" rows="5" cols="50" wrap="off">Enter anything you want in this TextArea input box.</textarea></form>
If you have multiple TextBoxes in your html page, change "MyTextBox" into some other names, such as "MyTextBox1", for the other boxes...
Here is what it does:
Enter anything you want in this TextArea input box.
Tutorial of how the code works:
Programming logic:
Create a html form
Use pre-defined javascript methods in
form
objects with "
MyTextBox
" defined as the name of the textarea box you want to highlight:
this.form.MyTextBox.focus
and
this.form.MyTextBox.select
Set up the textarea box with the name "
MyTextBox
" containing whatever text you want to display there.
Run-time logic:
Invoke the above methods when mouse click on input button.
Usage:
Click ""Highlight text below"" button to select the text inside the textbox below.
Feedback
How useful do you rate this javascript?
Excellent
Good
Neutral
Poor
Current Results
Create a FREE Alxnet Web Poll
Home Page
|
Javascript Resources
|
php Resources
Copyright © 2003
Computational Neural Systems
Inspired by
The Personal Best