Skip to main content
Participating Frequently
February 12, 2010
Question

Javascript value of a textarea with richtext?

  • February 12, 2010
  • 1 reply
  • 2119 views

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?

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    February 14, 2010

    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>