Posts | Comments

So I’m continuing the problem of my coldfusion array building.

What I’ve got is a series of checkboxes in a form. What I need to do is take any checked (or ‘on’) items and create a comma-sep list of the names of the variables.

I attempted to use an if(isdefined…){ add to an array } but it’s not working as planned. Here’s the code I’m using:

  1. checkedItems = ArrayNew(1);     if(isdefined("form.heat1")){
  2.  
  3. checkedItems[1] = "heat1";
  4.  
  5. }
  6.  
  7. if(isdefined("form.heat2")){
  8.  
  9. checkedItems[2] = "heat2";
  10.  
  11. }
  12.  
  13. if(isdefined("form.heat3")){
  14.  
  15. checkedItems[3] = "heat3";
  16.  
  17. }
  18.  
  19. if(isdefined("form.tied")){
  20.  
  21. checkedItems[4] = "tied";
  22.  
  23. }
  24.  
  25. if(isdefined("form.notcontested")){
  26.  
  27. checkedItems[5] = "notcontested";
  28.  
  29. }
  30.  
  31. if(isdefined("form.handtimed")){
  32.  
  33. checkedItems[6] = "handtimed";
  34.  
  35. }
  36.  
  37. if(isdefined("form.preliminaries")){
  38.  
  39. checkedItems[7] = "preliminaries";
  40.  
  41. }
  42.  
  43. if(isdefined("form.meetrecord")){
  44.  
  45. checkedItems[8] = "meetrecord";
  46.  
  47. }
  48.  
  49. if(isdefined("form.schoolrecord")){
  50.  
  51. checkedItems[9] = "schoolrecord";
  52.  
  53. }
  54.  
  55. if(isdefined("form.staterecord")){
  56.  
  57. checkedItems[10] = "staterecord";
  58.  
  59. }

The problem is, when I run through that if list, I end up with #1 as ‘heat1′ and #6 as ‘handtimed’ and 2-5 will be “[undefined array element].”

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Technorati

One Comment to “Continuing the CFML problem”

  1. jameswillisisthebest Says:

    This is my first post
    just saying HI

Leave your comment

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