943,724 Members | Top Members by Rank

Ad:
May 3rd, 2005
0

Accessing DOM Objects

Expand Post »
Hi,
here i enclosed my coding.i want the dom objects price,qty,oselect,name,sku and upc in the html body tag so that it can be submitted into another pages.
here i want each and every element in each row to be collected and sent to the next place not the last element alone plz help me
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title> working with jscript</title>
  4. <script type="text/javascript">
  5. function appendtable()
  6. {
  7. var parent = document.getElementById("divide");
  8. var div = document.createElement("div");
  9.  
  10. var tbl = div.appendChild(document.createElement("table"));
  11. var tb = tbl.appendChild(document.createElement("tbody"));
  12. var tr = tb.appendChild(document.createElement("tr"));
  13. var td = tr.appendChild(document.createElement("td"));
  14.  
  15. parent.appendChild(div);
  16.  
  17. var oSelect=document.createElement("select");
  18. var oOption = document.createElement("option");
  19. var t0 = document.createTextNode("Ferrari");
  20. oOption.setAttribute("value", 0);
  21. oOption.appendChild(t0);
  22. oSelect.appendChild(oOption);
  23.  
  24. var oOption1 = document.createElement("option");
  25. var t1 = document.createTextNode("Fessari");
  26. oOption1.setAttribute("value", 1);
  27. oOption1.appendChild(t1);
  28. oSelect.appendChild(oOption1);
  29.  
  30.  
  31. var pname=document.createElement("input");
  32. pname.type="text";
  33. pname.value="product name"
  34. pname.name = "pname";
  35.  
  36. var price=document.createElement("input");
  37. price.type="text";
  38. price.value="product price"
  39.  
  40. var qty=document.createElement("input");
  41. qty.type="text";
  42. qty.value="product quantity"
  43.  
  44. var sku=document.createElement("input");
  45. sku.type="text";
  46. sku.value="product SKU"
  47.  
  48. var upc=document.createElement("input");
  49. upc.type="text";
  50. upc.value="product UPC"
  51.  
  52. td.appendChild(oSelect);
  53. td.appendChild(pname);
  54. td.appendChild(price);
  55. td.appendChild(qty);
  56. td.appendChild(sku);
  57. td.appendChild(upc);
  58. oSelect.onchange=function(){ txtChange(this,pname,price,qty,sku,upc); }
  59. }
  60.  
  61. // get element with name from parent node...
  62. function elementOfName(parentNode, name){
  63. var nodeList = parentNode.getElementsByTagName("INPUT");
  64. for(var i=0; i<nodeList.length; i++){
  65. if(nodeList.item(i).name == name){
  66. return nodeList.item(i);
  67. }
  68. }
  69. return null;
  70. }
  71.  
  72. function txtChange(obj,pname,price,qty,sku,upc){
  73.  
  74. var pname = elementOfName(obj.parentNode, "pname");
  75. //var price = elementOfName(obj.parentNode, "price");
  76. var pQty = elementOfName(obj.parentNode, "qty");
  77. var SKU = elementOfName(obj.parentNode, "price");
  78. var UPC = elementOfName(obj.parentNode, "qty");// this is not working i dont know why....
  79.  
  80.  
  81. }
  82. </script>
  83. </head>
  84. <body bgcolor=white>
  85.  
  86. <FORM ACTION=dlist.html METHOD=POST>
  87. Purchase Order ID <input type="text" name="poId"><br>
  88. Sendor Address <input type="text" name="senderAddress"><br>
  89. Vendor Address <input type="text" name="vendorAddress"><br>
  90. poStatus <input type="text" name="poStatus"><br>
  91. poDate <input type="text" name="poDate"><br>
  92. expDate <input type="text" name="expDate"><br><br>
  93. <h4> Product Details</h4>
  94. <input type="button" onclick="appendtable()" value="Add Product">
  95. <div id="divide"></div>
  96. <input type="hidden" name=pId>//here i m sending eachand every product to submitted into the next page
  97. <input type="hidden" name=pName>
  98. <input type="hidden" name=price>
  99. <input type="hidden" name=pQty>
  100. <input type="hidden" name=SKU>
  101. <input type="hidden" name=UPC>
  102. <br> <input type="submit" name="btnSubmit" value="Submit Order">
  103. </form>
  104. </body>
  105. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nandoo is offline Offline
14 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Please help me make this script work in Netscape
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Creating Hit Counters for a website





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC