Processing a dynamic form with arbitrary # of FORM variables
Posted: Thu May 22, 2003 11:46 am
I imagine this has got to be possible, but I'm not sure where to start...
I'm creating a database-driven menu system for an application here at work. Right now I'm working on some simple administration tools to allow me to configure various settings. One of the things is a list of servers, and some various attributes that can be set either on or off. What I want to do is display this as a table within a form, so that I can check various boxes and save the configuration changes I just made.
I have the table working, queries the database and presents the existing settings just right - one row in the table per database result row, which may be an arbitrary number of rows, depending upon the query that generates the form. I also create unique names for each of the various flags, like FLAG_A_1, where the FLAG_A part corresponds to the particular flag I might want to update, and the _1 reflects that this flag is relative to the result row with a unique identifier of "1".
I might also try to encode the FORM variable names as an array, such as FLAG_A[1], FLAG_A[2], but haven't as yet been able to read the variables in as an array on the form-processing side.
What I can't quite get my head around is how to parse the submitted form - since there may be an arbitrary number of rows in my result, how do I know what variables are being passed when the form is submitted? Is there an elegant way for the form processing script (the ACTION script in my form) to self-discover what variables are available, or do I need to do something hokey, like pass a hidden variable/variables with the array of result row IDs so I can correctly assemble the variables in the receiving script?
Thanks in advance...
Tim
I'm creating a database-driven menu system for an application here at work. Right now I'm working on some simple administration tools to allow me to configure various settings. One of the things is a list of servers, and some various attributes that can be set either on or off. What I want to do is display this as a table within a form, so that I can check various boxes and save the configuration changes I just made.
I have the table working, queries the database and presents the existing settings just right - one row in the table per database result row, which may be an arbitrary number of rows, depending upon the query that generates the form. I also create unique names for each of the various flags, like FLAG_A_1, where the FLAG_A part corresponds to the particular flag I might want to update, and the _1 reflects that this flag is relative to the result row with a unique identifier of "1".
I might also try to encode the FORM variable names as an array, such as FLAG_A[1], FLAG_A[2], but haven't as yet been able to read the variables in as an array on the form-processing side.
What I can't quite get my head around is how to parse the submitted form - since there may be an arbitrary number of rows in my result, how do I know what variables are being passed when the form is submitted? Is there an elegant way for the form processing script (the ACTION script in my form) to self-discover what variables are available, or do I need to do something hokey, like pass a hidden variable/variables with the array of result row IDs so I can correctly assemble the variables in the receiving script?
Thanks in advance...
Tim