Solved

Clear cftextarea with button

Posted on 2014-11-14
1
130 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …

726 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