Dynamically add text into body as I click and inserting it into the where of a query statement potentially? – user3440142 Mar 20 '14 at 05:07

  • http://stackoverflow.com/questions/10602470/submitting-a-form-when-a-checkbox-is-checked has some examples. (Just ignore the PHP ness) – James A Mohler Mar 20 '14 at 05:10
  • Didn't answer the question. I want to click one of the options in my "listbox" to active the click. – user3440142 Mar 20 '14 at 05:44
  • 2
    Why, in the name of all that is holy, are you using Access? Access is not designed to be the back end for web applications. You will hit performance issues. Try something better/cheaper like MySQL or PostgreSQL. – Scott Stroz Mar 20 '14 at 13:26
  • How to submit from a select: http://stackoverflow.com/questions/7231157/how-to-submit-form-on-change-of-dropdown-list – James A Mohler Mar 20 '14 at 14:25
  • 1 Answers1

    -1

    Let me try to redeem myself with a modified answer:

    You can dynamically reapply options to elements using ajax calls to your cfc file (since cfc bind is apparently a no-no) by adding an event listener to the first select field and calling the method in the cfc file via an AJAX get request. In the success function, you can then update the response to the textarea field.

    Every time a selection is made from the select box, the text box will refresh the data with the appropriate query result.

    The HTML page could look something like this:

    <script type="text/javascript">
        document.forms['yourformname'].elements['LoopPosts'].addEventListener('click', function(){
        $.ajax({
          type:"GET",
          url: "yourcfcfilename.cfc?method=GetSelectedPost",
          data: {selectedPost : this.value},
          success: function(response) {
            document.forms['yourformname'].elements['PostBody'].innerHTML = response;
          },
          error : function(XMLHttpRequest, textStatus, errorThrown) { 
            alert("Status: " + textStatus); alert("Error: " + errorThrown); 
          }
        });
      });
    </script>
    

    And the cfc page could look something like this:

    <cfcomponent displayname="Post Functions" output="true">
    
      <!--- Secondary Query --->
      <cffunction name="GetSelectedPost" access="remote" returntype="String">
        <cfargument name="selectedPost" type="string" required="true">
    
          <cfquery name="PostsQuery" datasource="Postings">
            SELECT PostBody
            FROM BlogPosts
            WHERE PostID = <cfqueryparam value="ARGUMENTS.selectedPost">
          </cfquery>
    
          <cfreturn PostsQuery.PostBody>
      </cffunction>
    
    </cfcomponent>
    

    Every time a selection is made from the select box, the text box will refresh the data with the appropriate query result.

    dbetke
    • 28
    • 5
    • 3
      I do not recommend using this approach. ColdFusionUI is unreliable at best. Your best bet is to use jQuery AJAX. – Cory Fail Mar 20 '14 at 12:49
    • 1
      Yea...don't use `cffrom`, `cfselect` or any other CF UI elements. They are more trouble than they are worth. – Scott Stroz Mar 20 '14 at 13:24
    • Works with the listbox by itself. The cftextarea however says `[object Object]`. Reading what cftextarea supports, it seems that display isn't one of them. – user3440142 Mar 20 '14 at 16:21
    • Changed `WHERE PostID = ` to `#selectedPost#` on the assignment side. Within another ` – user3440142 Mar 20 '14 at 18:09
    • Your recent changes cause this message: "The specified remote function GetPosts was not found on the CFC EditPosts." – user3440142 Mar 20 '14 at 18:31
    • Your first answer is technically working after I switched to state the variable #selectedPost# (as shown on the CF documentation http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_a-b_6.html). It is just that any control that isn't a ` – user3440142 Mar 20 '14 at 18:38
    • Maybe the return type in the cfc function needs to be changed to string? – dbetke Mar 20 '14 at 18:59
    • The method works. Found this example on a website that used more than just Select statements. http://www.raymondcamden.com/index.cfm/2009/10/18/Ask-a-Jedi-ColdFusion-Ajax-example-of-retrieving-fields-of-data – user3440142 Mar 21 '14 at 00:53