Reply
[JavaScript] Highlight Text Area Button
Old 05-15-2005, 03:11 PM [JavaScript] Highlight Text Area Button
rogem002's Avatar
Webmaster Talker

Posts: 611
Name: Mike
Location: United Kingdom
You may have noticed around the Bravenet site that whenever you want you to copy code from a text area they provide you with a button that will highlight all of the code for you to copy and paste onto your website. Well i thought i will share that code snippet with you as it can be very handy.

This is how to code the feature:

<form name="copyThis">
<textarea name="codeToCopy" cols="40" rows="5" readonly="readonly">
Click on the button below to highlight this text.
</textarea>
<br>
<input type="button" value="Highlight All" onclick="javascript:this.form.codeToCopy.focus();t his.form.codeToCopy.select();">

</form>


Copy the code and paste the code between the <body> and </body> of your HTML document.


Remember that if you would like to have several different highlightable text areas on the same page you will have to change the 'name' of the text area and ensure that the new name is replaced in the 'onclick' event of the button.

In addition, it is not a bad idea to get in the habit of replacing all tags within the text area with special characters to avoid the code in the text area from interfering with the html displaying your page. The special character for an opening tag '<' is &lt; and a closing tag '>' is &gt;.



Written by Bravenet.com, Changed my Rogem for forum use and more easy reading.
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
When You Register, These Ads Go Away!
Old 08-07-2005, 01:56 PM
Harvey's Avatar
Super Spam Talker

Posts: 901
Name: Harvey C
Location: Brighton, UK
Thanks! Just searched for that and really needed it - perfect!
__________________
Buy wii fit|Gift ideas
Harvey is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to [JavaScript] Highlight Text Area Button
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11020 seconds with 12 queries