- Forums
- Javascipt
- Javascript Select All Text Form Button Textarea With Java Script Focus()
this page shows you how you can select all the text from a textarea using javascript, i give you an example and a demo using javascript focu() function [785], Last Updated: Sat May 18, 2024
webmaster
Fri Dec 22, 2006
14 Comments
9412 Visits
have you ever seen those cool tricks on other websites where they have the code and to copy the code they have a submit form so you can hightlight all the text in the text area, well this script below will show you how you can do this. you can learn from this simple code by copy and paste into a text editor link notepad and save it, then upload to your website to see it in action.
here is a demo:
and here is the code: Courtesy of www.webune.com
<html>
<title>Cool Javascript Tricks Select All Code From Textarea Form</title>
<body bgcolor="#FFFFFF">
<center>
<form name="select_all">
<textarea name="text_area" rows="10" cols="80">
Wallpaperama is an amazing collection of High quality, high resolution wallpapers for your computer desktop for free. Download your favorite high resolution wallpaper for free at wallpaperama.com. Our free wallpapers include a large collection of wallpapers for your computer desktop. You will find only free wallpapers, no pop-up ads, no spam, no spyware only high quality free wallpapers for your computer background. Surf with confidence.
</textarea>
<br>
<input type="button" value="Highlight Text" onClick="javascript:this.form.text_area.focus();this.form.text_area.select();">
</form>
</center>
</body>
</html>
please tell me if this was helpful. if it was not please tell me what you were looking for. i would appreciate your comments. i want to help anyone. i have extensive knowledge in javascript and i might be able to help you in what you are looking for. my scripts/snippets are free. please feel free to ask any questions you may have
i have a problem,i opened another site in my project using i frame, so whatever user selectes in the other site has to be copied using js how should i do this,any idea.