3 Replies Latest reply on Apr 19, 2006 12:29 AM by BKBK

    Using CF to create a JS function

    Botman63
      I am using ColdFusion to create a JS array. The array is populated just fine but it is not working, nor do I get any errors. I have attached the original code and the result. Any assistance would be appreciated.

      Thanks,

      Bruce
        • 1. Re: Using CF to create a JS function
          BKBK Adobe Community Professional & MVP
          it is not working
          Where is the call to the function populateData() ?


          • 2. Re: Using CF to create a JS function
            mr. modus Level 1
            From what I can tell from your loop you aren't actually looping through the result set, just running a loop as large as the record count.

            Try this and let me know if it's the fix.
            Otherwise try being a little more detailed.
            • 3. Using CF to create a JS function
              BKBK Adobe Community Professional & MVP
              Mr. Moduswrote:
              From what I can tell from your loop you aren't actually looping through the result set, just running a loop as large as the record count.
              I thought so, too. But then, Botman63 says, "The array is populated just fine ". There's nothing wrong with his code. So long as what he wants is that all the elements of arrayData should have the same value. However, your remark -- decrement to adjust to array indices in JS -- makes me now think that that might not be what Botman63 wanted.

              Try this and let me know if it's the fix.
              <cfoutput query="qCompanyClientNames">
              arrayData[#DecrementValue(CurrentRow)#] = '#CoName#|[#CoName#] #ClName#|'
              </cfoutput>


              Here's another suggestion, based on Botman63's own code. It simply adds the indices x+1.

              <cfset Records = #qCompanyClientNames.RecordCount# - 1>
              var arrayData = new Array();
              <cfoutput>
              <cfloop from=0 to=#Records# index=x>
              arrayData[#x#] = '#qCompanyClientNames.CoName[x+1]#|[#qCompanyClientNames.CoName[x+1]#] #qCompanyClientNames.ClName[x+1]#|'
              </cfloop>
              </cfoutput>