code_junkie

How do you structure an infinitely scalable form using Javascript?

Nov 12th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <div id="product1"></div>
  2. <div id="product2"></div>
  3. <div id="product3"></div> etc...
  4.  
  5. document.getElementById('product').innerHTML += <input name="product">
  6.  
  7. $("someContainerDiv").insert(new Element("div", { id: "product_"+prodId, 'class':'prod' }))
  8.  
  9. output = '';
  10. for(i in products){
  11. output += '<div id="product_' + products[i].id + '">';
  12. output += '<input type="text" name="products[' + products[i].id + '][name]">';
  13. output += '<input type="text" name="products[' + products[i].id + '][price]">';
  14. output += '</div>';
  15. }
  16. $('#products_list').append(output);
Add Comment
Please, Sign In to add comment