Welcome Guest Search | Active Topics | Members

[JavaScript] Highlight Text Area Button Options
rogem002
Posted: Tuesday, March 29, 2005 9:22:07 AM

Rank: Martian Estate Agent

Joined: 9/14/2003
Posts: 3,358
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();this.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 < and a closing tag '>' is >.



Written by Bravenet.com, Changed my Rogem for forum use and more easy reading.


Full On Design
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.