Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript value of a textarea with richtext?

New Here ,
Feb 12, 2010 Feb 12, 2010

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?

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2010 Feb 14, 2010
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources