Creating Dynamic Form With PHP
Posted: Mon Jun 11, 2007 11:13 pm
I'm trying to create a basic HTML form, but I want it to be a bit dynamic. I know how to create HTML forms, and I know how to process them using PHP.
However, here is what I want in the form...
I want to have some options or a button (other than submit). I want the user to be able to click 'add' or something to add another group of fields. Once they click 'add' or something along those lines, it will put a whole new group of fields. The fields are all the same, although the values will end up different.
Is there a 'graceful' way to pull this off and have a nice looking form that is easy to understand and use? I realize some issues may come up dealing with naming - would need to increment the names and keep count so that I can process them with a script.
I could probably pull it off without too much trouble by doing it in two forms...first page ask 'how many will you have' type question, and then just run a for loop to add all the fields each 'section' will contain. Would that be a better way? It seems like it might be easier, as I can probably pull it off myself now.
I'm just looking for the best way to do it and create a nice form that is dynamic with the fields. I can just run foreach in the processing script, so the actual number isn't too important on that end.
However, here is what I want in the form...
I want to have some options or a button (other than submit). I want the user to be able to click 'add' or something to add another group of fields. Once they click 'add' or something along those lines, it will put a whole new group of fields. The fields are all the same, although the values will end up different.
Is there a 'graceful' way to pull this off and have a nice looking form that is easy to understand and use? I realize some issues may come up dealing with naming - would need to increment the names and keep count so that I can process them with a script.
I could probably pull it off without too much trouble by doing it in two forms...first page ask 'how many will you have' type question, and then just run a for loop to add all the fields each 'section' will contain. Would that be a better way? It seems like it might be easier, as I can probably pull it off myself now.
I'm just looking for the best way to do it and create a nice form that is dynamic with the fields. I can just run foreach in the processing script, so the actual number isn't too important on that end.