Solved

Clear cftextarea with button

Posted on 2014-11-14
1
115 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now