Posts | Comments

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).

Score-It Screenshot of tracking team scores

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:

another screenshot

Update: DanWilson in #coldfusion (on IRC) has come up with the answer:

  1. <cfloop List="#TeamID#" index="thisTeamID">
  2. <cfset whatWeWant = "scoring_1_" & thisTeamID />
  3. <cfif structKeyExists( form, whatWeWant)>
  4. <cfquery name="insertTeamRow" datasource="HSST">
  5. INSERT INTO CEdge.TRACK_TEAM_SCORE
  6. (gameTeamID,teamScore1,gameID)
  7. VALUES
  8. (’#thisTeamID#’,'#form[whatWeWant]#’,'#gameID#’)
  9. </cfquery>
  10. </cfif>  
  11. </cfloop>
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Technorati

One Comment to “Silly Coldfusion and form issue SOLVED”

  1. Chad Edge Says:

    Dan, thank you so much for the help. Invaluable!

Leave your comment

chadedge dot-com is powered by WordPress. Design by Nofie Iman.