?
Solved

Clear cftextarea with button

Posted on 2014-11-14
1
Medium Priority
?
135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 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

Stack Overflow Podcast - Frustrating Miracles

In this podcast, Stack Overflow interviewed Linux Academy CEO/Founder, Anthony James, and got his developer story!

"Follow your passion, be prepared to work hard and sacrifice, and, above all, don't let anyone limit your dreams."  - Donovan Bailey

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

743 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