Handling Form Data - Array in PHP
Posted: Sat Feb 06, 2010 4:27 pm
Hi,
There're two web pages:
1: formData.html
2: processData.php
The formData.html (in browser) web page looks like as follows:
Well, let me give some explanation here: There's a Table to which a new row is dynamically added. Each row consists of 3 cells (text fields in them in fact).
I have no problem with this file.
Now, the crucial part comes when Submit button is clicked and processData.php is called via POST method.
The problem which I am facing is that as the Number of Rows is not predetermined and may vary moreover each Row has 3 Text Fields having unique ID, so, how to handle the Form Data passed to the PHP file in a case like this where we don't know any Element ID or Name in advance?
Note: A code fragment found in the html form for adding a new Row or Item Line:
I think we need to handle Array using the $_POST or $_REQUEST function. Any help, guys?
There're two web pages:
1: formData.html
2: processData.php
The formData.html (in browser) web page looks like as follows:
Code: Select all
-------------------------------
Case No | Summary | Details
-------------------------------
1 | XYZ | Blah-Blah!
2 | XYZ | Blah-Blah!
3 | XYZ | Blah-Blah!
N | XYZ | Blah-Blah!
I have no problem with this file.
Now, the crucial part comes when Submit button is clicked and processData.php is called via POST method.
The problem which I am facing is that as the Number of Rows is not predetermined and may vary moreover each Row has 3 Text Fields having unique ID, so, how to handle the Form Data passed to the PHP file in a case like this where we don't know any Element ID or Name in advance?
Note: A code fragment found in the html form for adding a new Row or Item Line:
Code: Select all
var newCell1 = newRow.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow[]';
el.id = 'txtRow' + iteration;
el.size = 20;
newCell1.appendChild(el);