So I’ve got this form. On this form will be [n] number of teams, displayed as a text label (the school’s full name), a textfield with the acronym for the school, and a textfield with the option to enter a team score for a scheduled event.
The problem I’m having is this: let’s say you have 8 schools listed, but only have scores for numbers 1-6 and 8 (#7 is missing a score). If you attempt to leave the 7th school blank and save the form, number 8 will appear blank and #7 will inherit the score of #8 (see the screenshot).

The variables I’m dealing with are stored as an array of ‘teamID[n]‘ ‘teamAcronym[n]‘ and ‘teamScore[n].’ If you loop through the array, you will have 1-n of scores, only storing when a variable is in-fact loaded (meaning the array doesn’t have an empty slot, such as [1,2,3,4,5,6,8]).
Any thoughts on updating this list? Perhaps I could change the id’s of the teamScore[n] to ‘teamScore[teamID]‘?
I know how to do this in PHP but so-far ColdFusion doesn’t support me well.
Sigh.
Update: an addition for ADP1207 on #coldfusion:
cfdump:

Update: DanWilson in #coldfusion (on IRC) has come up with the answer:
-
<cfloop List="#TeamID#" index="thisTeamID">
-
<cfset whatWeWant = "scoring_1_" & thisTeamID />
-
<cfif structKeyExists( form, whatWeWant)>
-
<cfquery name="insertTeamRow" datasource="HSST">
-
INSERT INTO CEdge.TRACK_TEAM_SCORE
-
(gameTeamID,teamScore1,gameID)
-
VALUES
-
(’#thisTeamID#’,'#form[whatWeWant]#’,'#gameID#’)
-
</cfquery>
-
</cfif>
-
</cfloop>
Categories