Im creating a basic function to submit product skus and quantities to another page
i am created the form elements for the quantities in a popup div based on items selected on the current page.
I am looping round those, and creating an input field for each
i need each input field to be submitted with the post of the main form on the page
here is my function
for some reason even thought the input fields are being appended to a div inside the main form... they are not submitted when the form is posted.
Thanks for you help.
Rob
Expand|Select|Wrap|Line Numbers
- function addToPackage()
- {
- var items = document.itemlist.item_id;
- var checkeditems = 0;
- var itemsku;
- var itemQtyDiv;
- var itemQtyInput;
- var itemQtyLabel;
- var itemQtyText;
- editQtyLayer = document.getElementById('packageqtychoice');
- for(i=0;i<items.length;i++)
- {
- if(items[i].checked)
- {
- checkeditems++;
- itemsku = items[i].value;
- //add the div section for this sku
- itemQtyDiv = document.createElement("div");
- itemQtyDiv.setAttribute("id", "item_container_"+itemsku);
- editQtyLayer.appendChild(itemQtyDiv);
- itemQtyDiv = document.getElementById('item_container_'+itemsku);
- //add the label for the text
- itemQtyLabel = document.createElement("label");
- itemQtyLabel.setAttribute("id", "item_label_"+itemsku);
- itemQtyLabel.setAttribute("for", "item_qty_"+itemsku);
- itemQtyDiv.appendChild(itemQtyLabel);
- //create text node
- itemdescription = document.getElementById('item_description_'+itemsku).innerHTML;
- itemQtyText = document.createTextNode(itemdescription);
- //add the text to the label
- itemQtyLabel = document.getElementById('item_label_'+itemsku);
- itemQtyLabel.appendChild(itemQtyText);
- //finally create the qty input
- itemQtyInput = document.createElement("input");
- itemQtyInput.setAttribute("type", "text");
- itemQtyInput.setAttribute("size", "2");
- itemQtyInput.setAttribute("name", "item_qty_"+itemsku);
- itemQtyInput.setAttribute("id", "item_qty_"+itemsku);
- itemQtyInput.setAttribute("value", "");
- itemQtyDiv.appendChild(itemQtyInput);
- }
- }
- if(checkeditems>0)
- {
- editQtyLayer.innerHTML = '<a href="javascript:void(0);" onclick="__cancelToPackage();">Cancel</a><br /><b>Enter Quantities included in package</b>'+editQtyLayer.innerHTML;
- editQtyLayer.innerHTML = editQtyLayer.innerHTML+'<br /><br /><a href="javascript:void(0);" onclick="__sendToPackage(); return false;"><b>Proceed to choose a package</b></a>';
- editQtyLayer.style.display='block';
- }
- else
- {
- alert('You have not chosen any items');
- }
- }