Hey all Trying to generate a 1-button form that will go in a cell of a table. The catch is that this needs to be generated dynamically in javascript. The table has a couple other values. I did the table first without the form part and everything was working fine... Now the table doesn't generate at all.
I know the way I'm generating the form is incorrect but I'm not sure why.... Please help!
Thanks
function populateInventory() {
clearTable(); //This works
var artistIndex = byId('artist').selectedIndex;
var albumIndex = byId('albumSelect').selectedIndex;
var inventoryArray = inventoryNames[artistIndex][albumIndex];
for (i = 0; i < inventoryArray.length; i++) {
var idValue = inventoryArray[i][2];
var conditionValue = inventoryArray[i][3];
var priceValue = inventoryArray[i][4];
var table = byId('table');
var row = table.insertRow(i + 1);
var submitCell = row.insertCell(0);
var idCell = row.insertCell(1);
var conditionCell = row.insertCell(2);
var priceCell = row.insertCell(3);
//Begin problem?!
var form = document.createElement("form");
form.method = "post";
form.action = "<?php echo $_SERVER[PHP_SELF];?>";
var inventoryIdElement = document.createElement("<input name='inventoryIdElement' type='hidden' value='" + idValue + "' ></input>");
form.appendChild(inventoryIdElement);
var submitElement = document.createElement("<input name='submit' type='submit' value='Remove' ></input>");
form.appendChild(submitElement);
//End problem?!
var idElement = document.createTextNode(idValue);
var conditionElement = document.createTextNode(conditionValue);
var priceElement = document.createTextNode("$" + priceValue);
submitCell.appendChild(form);
idCell.appendChild(idElement);
conditionCell.appendChild(conditionElement);
priceCell.appendChild(priceElement);
}
}