Skip to main content
Known Participant
March 27, 2010
Question

How to select contents of form cftextarea after submitting form

  • March 27, 2010
  • 2 replies
  • 491 views

I was wondering what is the way to select the contents of a cftextarea after submitting a cfform and that same page gets reloaded with cfform preservedata="yes".

    This topic has been closed for replies.

    2 replies

    Known Participant
    March 28, 2010

    The Forta Blog, http://www.forta.com/blog/index.cfm/2008/2/15/ColdFusion-Rich-Text-Control-And-Safari mentioned that there is a FCKEditor which allows you to add rich text control using <cftextarea rightext="true">, but the biggest gotcha with this control is the FCKEditor didn't support Safari for ColdFusion 8, which is the version that I am using.

    So I guess that there may be no way to access the cftextarea. When you look at the source page it is not visible, but you can see:

    <script type="text/javascript" charset='utf-8'>

         document.write("<embed pluginspage='http://www.macromedia.com/go/getflashplayer' ");

          document.write("   id='fQuiz' ");
    ...

    </script>

    Where the id of the cfform is fQuiz.

    I guess there is no way then to modify the code so that I can automatically select the text inside the cftextarea instead of having to manually do that everytime I submit the form.

    Known Participant
    March 27, 2010

    If I try adding something like the following:

    onLoad = "selectText();"

    as an attribute of <cfform>, then the form doesn't display.

    Known Participant
    March 27, 2010

    This is true if you leave out the semicolon also:

    <cffrom ... onLoad = "selectText()">

    Known Participant
    March 27, 2010

    I am able to add onload to body tag, but I guess I have to look into how to select the text with a function when the form has preserveData enabled.