469,330 Members | 1,236 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

form elements created by not posting

hey.
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
  1. function addToPackage()
  2. {    
  3.     var items = document.itemlist.item_id;
  4.     var checkeditems = 0;
  5.     var itemsku;
  6.  
  7.     var itemQtyDiv;
  8.     var itemQtyInput;
  9.     var itemQtyLabel;
  10.     var itemQtyText;
  11.  
  12.     editQtyLayer = document.getElementById('packageqtychoice');    
  13.  
  14.     for(i=0;i<items.length;i++)
  15.     {
  16.         if(items[i].checked)
  17.         {
  18.             checkeditems++;
  19.  
  20.             itemsku = items[i].value;
  21.  
  22.             //add the div section for this sku
  23.             itemQtyDiv = document.createElement("div");
  24.             itemQtyDiv.setAttribute("id", "item_container_"+itemsku);
  25.             editQtyLayer.appendChild(itemQtyDiv);
  26.             itemQtyDiv = document.getElementById('item_container_'+itemsku);
  27.  
  28.             //add the label for the text
  29.             itemQtyLabel = document.createElement("label");
  30.             itemQtyLabel.setAttribute("id", "item_label_"+itemsku);
  31.             itemQtyLabel.setAttribute("for", "item_qty_"+itemsku);
  32.             itemQtyDiv.appendChild(itemQtyLabel);
  33.  
  34.             //create text node        
  35.             itemdescription = document.getElementById('item_description_'+itemsku).innerHTML;
  36.             itemQtyText = document.createTextNode(itemdescription);
  37.  
  38.             //add the text to the label
  39.             itemQtyLabel = document.getElementById('item_label_'+itemsku);
  40.             itemQtyLabel.appendChild(itemQtyText);
  41.  
  42.             //finally create the qty input
  43.             itemQtyInput = document.createElement("input");
  44.             itemQtyInput.setAttribute("type", "text");
  45.             itemQtyInput.setAttribute("size", "2");
  46.             itemQtyInput.setAttribute("name", "item_qty_"+itemsku);
  47.             itemQtyInput.setAttribute("id", "item_qty_"+itemsku);
  48.             itemQtyInput.setAttribute("value", "");
  49.             itemQtyDiv.appendChild(itemQtyInput);
  50.  
  51.         }
  52.     }
  53.  
  54.     if(checkeditems>0)
  55.     {
  56.         editQtyLayer.innerHTML = '<a href="javascript:void(0);" onclick="__cancelToPackage();">Cancel</a><br /><b>Enter Quantities included in package</b>'+editQtyLayer.innerHTML;
  57.         editQtyLayer.innerHTML = editQtyLayer.innerHTML+'<br /><br /><a href="javascript:void(0);" onclick="__sendToPackage(); return false;"><b>Proceed to choose a package</b></a>';
  58.         editQtyLayer.style.display='block';
  59.     }
  60.     else
  61.     {
  62.         alert('You have not chosen any items');
  63.     }
  64. }
  65.  
  66.  
Apr 13 '07 #1
1 1419
acoder
16,027 Expert Mod 8TB
This link should help anyone with a similar problem.
Feb 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jeremy Langworthy | last post: by
1 post views Thread by Will | last post: by
2 posts views Thread by Mark Hannon | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.