Solved

Clear cftextarea with button

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

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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