Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

CF array var to Jscript array var

Question posted by: jenninnifer (Newbie) on March 19th, 2008 08:31 PM
This doesn't seem to be working... I am trying to send an array to my jscript, but am having problems. I query my db, populate the array (which is working), convert using wddx and try to get the length when my input changes (this is what is not working) - please help!!! Code is as follows:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <cfquery datasource="xxxx" name="get_dates">
  3.     select * from wwa_cycles where active_cycle = 1
  4. </cfquery>
  5.  
  6. <!--Create/Populate the array-->
  7. <cfset WWAverageArray = ArrayNew(2)>
  8.  
  9. <!--Adding the results to the array-->
  10. <cfif #get_dates.recordcount# neq 0 >
  11.     <cfloop query="get_dates">    
  12.         <cfset WWAverageArray[CurrentRow][1] = cycle>
  13.         <cfset WWAverageArray[CurrentRow][2] = begin_wwa_month>
  14.         <cfset WWAverageArray[CurrentRow][3] = end_wwa_month>
  15.         <cfset WWAverageArray[CurrentRow][4] = days_in_month_1>
  16.     </cfloop>
  17. </cfif>    
  18.  
  19.  
  20. <!---cfdump var="#WWAverageArray#"--->

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
  2.  
  3. function get_read_dates(in_cycle){
  4.     <CFWDDX action="CFML2JS" input="#WWAverageArray#" toplevelvariable="jsAvgArray" output="jsArray">
  5.     <cfoutput>#jsAvgArray#</cfoutput>
  6.     alert(jsAvgArray.length);
  7. }
  8. </SCRIPT>
  9. </head>
  10. <body>
  11.  
  12.  
  13. <form action="wwaverage_calculator.cfm" method="post" name="thisform">
  14. <input type="text" name="meter_read_cycle" size="5" maxlength="2" onChange="get_read_dates(this.value)"/>
  15. </form>
acoder's Avatar
acoder
Site Moderator
11,635 Posts
March 20th, 2008
04:37 PM
#2

Re: CF array var to Jscript array var
Give an example of an array.

Note that the way you've coded, the length will always be the same.

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,939 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Coldfusion Forum Contributors