• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using CF to create a JS function

New Here ,
Apr 18, 2006 Apr 18, 2006

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

297

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2006 Apr 18, 2006

Copy link to clipboard

Copied

it is not working
Where is the call to the function populateData() ?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

LATEST
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>




Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2006 Apr 18, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation