Copy link to clipboard
Copied
I can't figure out how to get the value of a text area with rich text. If I select richtext="false" the javascript ColdFusion.getElementValue('textareaName') works fine, but when richtext="true", this no longer works. Any ideas?
Copy link to clipboard
Copied
I think it's the other way round. ColdFusion.getElementValue('textareaName') should work when richtext="true". In my test, it did. But it failed when I changed to richtext="failed".
That is probably because ColdFusion.getElementValue() is designed to work only for bindable fields. Whereas the setting richtext="true" is bindable, the setting richtext="false" is not.
We could work around this by using a hidden field to make richtext="false"bindable, too. Something along these lines:
<script type="text/javascript">
function getText() {
var txt = ColdFusion.getElementValue('textareaName');
alert(txt);
return true;
}
</script>
<cfif isdefined("form.textareaName")>
<cfdump var="#form#">
</cfif>
<cfform name="myForm" id="myForm" onSubmit="return getText()">
<cftextarea name="textareaName" bindAttribute="richtext" bind="{yesOrNo}" richtext="false"></cftextarea>
<cfinput name="yesOrNo" type="hidden">
<cfinput type="submit" name="sbmt" value="Submit">
</cfform>