1 Reply Latest reply on Feb 2, 2009 10:56 AM by apocalipsis19

    cfcs starter

    kel45 Level 1
      Hi i have been playing around with cfc's

      what i would like to do is this

      i have created 2 functions the first gets a list of groups

      then the second get a list of names passing in the groupid variable

      groupname1
      name1
      name2
      name3
      groupname2
      groupname3

      what i need is to have the groupnames as links then onclick load the child names for that group

      can smeone help me please

      thank you in advance
        • 1. Re: cfcs starter
          apocalipsis19 Level 1
          I don't know if I properly understood your post but you don't really need a CFC to accomplish that. Second, this is the advanced forum, so this is not the right forum for an issue of this nature. Again, you didn't really explain why you need a CFC but I will try to reply to your post in the best of my abilities despite the lack of details in the information you provided.

          First of all, let's talk about CFCs. CFC is a coldfusion component and in my daily tasks I use CFCs to put together all the functions I use in the system and to put together some special functionality that I repeatedly use in my system. There are other uses depending on your system. What's your scenario? You can call CFCs by including it in your cfm files through <cfinclude>, by using <cfinvoke>, or by invoking your CFC in your session scope (those are the scenarios where I call my CFCs on a daily basis, this doesn't mean they are the only tecniques allowed.)

          But to accomplish what you want to accomplish you need two functions. Imagine that you created the function getGroups(), and get GroupMembers()

          <html>
          <head><title>Example</title></head>
          <body>
          <cfloop index="idx" from="1" to="#getGroups.recordcount#">
          <cfquery name="getMembersofGroup" datasource="#application.dsn#" dbtype="query">
          select * from groupmembers where group="#getGroups.groupId[idx]#"
          </cfquery>

          Group: #getGroups.GroupDesc[idx]#:
          <div id="divId_#idx#" onClick="JSFunctionThatShowandHidesDiv();">
          <table>
          <cfloop index="ind" from="1" to="#getMembersofGroup.recordcount#">
          <tr>
          <td>#groupMembers[ind]#</td>
          </tr>
          <cfloop>
          </table>
          </div>


          </cfloop>
          </body>
          </html>

          The next step is to create a small javascript function that hide and show html divs. I don't have time to type it for you, please research it. Let me give you a hint:

          document.getElementById('divId').style.visibility='hidden';
          or
          document.getElementById('divId').style.visibility='visible';

          I hope this helps and like I said, you did not really explain what you were trying to accomplish with your CFCs.

          Have a nice day!

          Ysais.