I am coding in Coldfusion MX7 and using Javascript for some of the functionality. The basic functionality I'm coding is, based on a value the user chooses from a dropdown box, I populate address fields with the associated data. I am using the onChange attribute of the dropdown box for the call to a Javascript function. I prepopulate a Coldfusion array with the address data and am using cfwddx to convert the Coldfusion array to a Javascript array. My problem is that the conversion doesn't seem to be working. The length of the Javascript array is 0, when it should be 3. Any suggestions?
Here's the relevant code:
Here's the relevant code:
Code:
<head>
function setRepositoryLocation(formValue)
{
<CFWDDX action="CFML2JS" input="#repositoryArray#" toplevelvariable="jsrepositoryArray">
alert(jsrepositoryArray.length);
for(i=0; i<jsrepositoryArray.length; i++)
{
if (jsrepositoryArray[i][0] == formValue)
{
document.frmInputSources.txtAddress1.value = jsrepositoryArray[i][1];
document.frmInputSources.txtAddress2.value = jsrepositoryArray[i][2];
document.frmInputSources.txtIDCountry.value = jsrepositoryArray[i][3];
document.frmInputSources.txtIDState_Province.value = jsrepositoryArray[i][4];
document.frmInputSources.txtCity.value = jsrepositoryArray[i][5]; document.frmInputSources.txtPostal_Code.value = jsrepositoryArray[i][6];
}
}
}
</script>
</head>
<body>
<CFSET arrIndex = 1>
<CFSET repositoryArray = ArrayNew(2)>
<CFOUTPUT QUERY="retSourceRepositories">
<CFSET repositoryArray[arrIndex][1] = #idSource_Repository#>
<CFSET repositoryArray[arrIndex][2] = #Address1#>
<CFSET repositoryArray[arrIndex][3] = #Address2#>
<CFSET repositoryArray[arrIndex][4] = #Country#>
<CFSET repositoryArray[arrIndex][5] = #State_Province#>
<CFSET repositoryArray[arrIndex][6] = #City#>
<CFSET repositoryArray[arrIndex][7] = #Postal_Code#>
<CFSET arrIndex = #arrIndex# + 1>
</CFOUTPUT>
<select style="float:left" name="txtIDSource_Repository" id="" class=""
onchange="javascript:if(this.value != 0) {setRepositoryLocation(this.value);}">
.
.
.
</select>
</body>
Comment