I have an html form that uses javascript to dynamically add more fields if needed by the user. Now I’m working on some php code to process the POST data that was submitted by the user. I need to know how many form fields were filled out, so I can process them all. My javascript does give each dynamicly added field a unique name and id by incrementing the name, and id by one each time. I can get all of the fields by doing a for each loop like this
foreach($_POST as $name=>$id) {
do something…;
}
I can also count the total amount of fields by using $total = count($_POST);
Neither one of these options works very well. I need to know how many of the dynamically added fields were used, so I can write their contents to a file along with a label (header) for each, as well as echo the values to the screen also with a label. Does anyone have any suggestions?