CF array var to Jscript array var

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jenninnifer
    New Member
    • Mar 2008
    • 1

    #1

    CF array var to Jscript array var

    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:

    [CODE=cfm]<head>
    <cfquery datasource="xxx x" name="get_dates ">
    select * from wwa_cycles where active_cycle = 1
    </cfquery>

    <!--Create/Populate the array-->
    <cfset WWAverageArray = ArrayNew(2)>

    <!--Adding the results to the array-->
    <cfif #get_dates.reco rdcount# neq 0 >
    <cfloop query="get_date s">
    <cfset WWAverageArray[CurrentRow][1] = cycle>
    <cfset WWAverageArray[CurrentRow][2] = begin_wwa_month >
    <cfset WWAverageArray[CurrentRow][3] = end_wwa_month>
    <cfset WWAverageArray[CurrentRow][4] = days_in_month_1 >
    </cfloop>
    </cfif>


    <!---cfdump var="#WWAverage Array#"--->
    [/CODE]
    [HTML]<SCRIPT LANGUAGE="javas cript" TYPE="text/javascript">

    function get_read_dates( in_cycle){
    <CFWDDX action="CFML2JS " input="#WWAvera geArray#" toplevelvariabl e="jsAvgArray " output="jsArray ">
    <cfoutput>#jsAv gArray#</cfoutput>
    alert(jsAvgArra y.length);
    }
    </SCRIPT>
    </head>
    <body>


    <form action="wwavera ge_calculator.c fm" method="post" name="thisform" >
    <input type="text" name="meter_rea d_cycle" size="5" maxlength="2" onChange="get_r ead_dates(this. value)"/>
    </form>[/HTML]
    Last edited by acoder; Mar 20 '08, 04:33 PM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Give an example of an array.

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

    Comment

    Working...