If I have a JavaScript array, say angleChanges = [a,b,c]
I want to store each of these values according to a user id (let's say it is an int). I am using SQL Server Management Studio and using ColdFusion to transfer variables to the server's SQL table. How do I loop through a JS array and transfer those values to the server? The user ID will be known ahead of time, but the array represent variables that will be unknown when the page loads. They will be created within the script. The values need to be stored in this way:
User ID:1 Array_Index:1 Array_Value:a
User ID:1 Array_index:2 Array_Value:b
User ID:1 Array_index:3 Array_Value:c
User ID:2 Array_index:1 Array_Value:a
User ID:2 Array_index:2 Array_Value:b
etc
for (var i = 1; i <= angleChanges.length; i++) {
/*index = document.createElement("index");
index.innerHTML = i;
document.body.append(index);*/
<cfquery datasource="exmind">
update dbo.sf_angles
set angle_change_number = i, angle_change = angleChanges[i-1]
where subject_id = #subject_id#
</cfquery>
}
This is what I want to do, but I do not know how to use i in cfquery, or the values in angleChanges (these would be the a,b,c values)