I wasn't sure if this should go in the JavaScript or PHP forum, so I decided JavaScript.
I have created a site that has a form where the user can create as many rows as wanted. I really have no idea how I can then get this information to use in PHP.
Here is my JavaScript function creating the rows:
Code:
function addDollyRow() {
numDollies++;
document.getElementById("numDollies").value = numDollies;
document.getElementById("removeDolly").disabled = false;
var dollyTable = document.getElementById('dollyTable');
var lastRow = dollyTable.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var row = dollyTable.insertRow(numDollies);
// two blank cells
var blankCellOne = row.insertCell(0);
var blankCellTwo = row.insertCell(1);
// dolly list
var dollyListCell = row.insertCell(2);
var dollyListSel = document.createElement('select');
dollyListSel.name = 'dollyListRow[]';
dollyListSel.id = 'dollyList' + numDollies;
dollyListSel.options[0] = new Option('','-1');
dollyListSel.options[1] = new Option('Regular Duty Dolly Set - Collins-4.80 \'C\'','1');
dollyListSel.options[2] = new Option('Heavy Duty Dolly Set - Collins-5.70 \'C\'','2');
dollyListSel.options[3] = new Option('Super Duty Dolly Set - Collins-5.70 \'D\'','3');
dollyListCell.appendChild(dollyListSel);
// dolly material list
var dollyMatCell = row.insertCell(3);
var dollyMatSel = document.createElement('select');
dollyMatSel.name = 'axleMaterial' + numDollies;
dollyMatSel.id = 'axleMaterial' + numDollies;
dollyMatSel.options[0] = new Option('','-1');
dollyMatSel.options[1] = new Option('Aluminum','1');
dollyMatSel.options[2] = new Option('Steel','2');
dollyMatCell.appendChild(dollyMatSel);
// quantity text cell
var qtyCell = row.insertCell(4);
var qtyInput = document.createElement('input');
qtyInput.type = 'text';
qtyInput.name = 'dollyQuantity' + numDollies;
qtyInput.id = 'dollyQuantity' + numDollies;
qtyInput.size = 3;
qtyCell.appendChild(qtyInput);
}
I read something about naming each element something such as 'el[]' and then iterating through it on the PHP side, but that didn't make much sense to me. I have only been using PHP for a few weeks now so I'm pretty new. Thanks for the help!