Solved

Clear cftextarea with button

Posted on 2014-11-14
1
125 Views
Last Modified: 2014-11-17
I have a simple cfform with a text area and I would like to have a "clear" button. I have tried using javascript and even just reset buttons but nothing seems to work. Could someone assist? Thank you.

<cfform name="textform" id="textform" method="post" action="#">
      <cftextarea name="textarea" width="500" height="400" toolbar="Basic" richtext="yes"></cftextarea>
</cfform>
0
Comment
Question by:earwig75
1 Comment
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 40442921
With "richtext" fields, the editor controls the field value. You need to use the editor to change the value. For CF9+, try:

<script type="text/javascript">
	function clearTextArea( elementName ) {
		// get reference to richtext field
		var obj = ColdFusion.RichText.getEditorObject(elementName);
		// clear the value
		obj.SetData("");		
	}
</script>
<cfform name="textform" id="textform" method="post" action="##">
    <cftextarea name="textarea" width="500" height="400" toolbar="Basic" richtext="yes"></cftextarea>
	<a href="javascript:clearTextArea('textarea')">Clear Text</a>
</cfform> 

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question