Urgent.....Dynamic Changes....

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: May 2005
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Urgent.....Dynamic Changes....

 
0
  #11
May 4th, 2005
Though I think you'd be surprised how much DOM you know now!
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 14
Reputation: nandoo is an unknown quantity at this point 
Solved Threads: 0
nandoo nandoo is offline Offline
Newbie Poster

Re: Urgent.....Dynamic Changes....

 
0
  #12
May 4th, 2005
hi foo,

U know i m working webMethods Integration part.In that i need the jsp page to get the input of purchase order.thats the reason i m working in jsp.to get the product details i went in the way of DOM.
but now i finished the part in webMethods but jsp makes me to struggle here.i did the changes what u advices but still no result.
could u please look into it deeply
pleas thanks a lot..
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. oSelect.onchange=function(){ txtChange(this); }
  30.  
  31. var prodname=document.createElement("input");
  32. prodname.type="text";
  33. prodname.value="product name";
  34. prodname.name = "prname";
  35.  
  36. var prodprice=document.createElement("input");
  37. prodprice.type="text";
  38. prodprice.value="product price";
  39. prodprice.name="prprice";
  40.  
  41. var prodqty=document.createElement("input");
  42. prodqty.type="text";
  43. prodqty.value="product quantity";
  44. prodqty.name="prqty";
  45.  
  46. var prodsku=document.createElement("input");
  47. prodsku.type="text";
  48. prodsku.value="product SKU";
  49. prodsku.name="prsku";
  50.  
  51. var produpc=document.createElement("input");
  52. produpc.type="text";
  53. produpc.value="product UPC";
  54. produpc.name="prupc";
  55.  
  56. td.appendChild(oSelect);
  57. td.appendChild(prodname);
  58. td.appendChild(prodprice);
  59. td.appendChild(prodqty);
  60. td.appendChild(prodsku);
  61. td.appendChild(produpc);
  62. }
  63.  
  64.  
  65. function elementOfName(parentNode, name)
  66. {
  67. var nodeList = parentNode.getElementsByTagName("INPUT");
  68. for(var i=0; i<nodeList.length; i++)
  69. {
  70. if(nodeList.item(i).name == name)
  71. {
  72. return nodeList.item(i);
  73. }
  74. }
  75. return null;
  76. }
  77.  
  78. function txtChange(obj)
  79. {
  80. document.getElementById("pName").value = elementOfName(obj.parentNode, "prname").value;
  81. document.getElementById("price").value = elementOfName(obj.parentNode, "prprice").value;
  82. document.getElementById("pQty").value = elementOfName(obj.parentNode, "prqty").value;
  83. document.getElementById("SKU").value = elementOfName(obj.parentNode, "prsku").value;
  84. document.getElementById("UPC").value = elementOfName(obj.parentNode, "prupc").value;
  85.  
  86. }
  87. </script>
  88. </head>
  89. <body bgcolor=white>
  90. <%@ taglib uri="http://webm-taglib.tld" prefix="webm" %>
  91. <FORM ACTION=http://10.200.13.83:5555/invoke/app/flowDList METHOD=POST>
  92. Purchase Order ID <input type="text" name="poId"><br>
  93. Sendor Address <input type="text" name="senderAddress"><br>
  94. Vendor Address <input type="text" name="vendorAddress"><br>
  95. poStatus <input type="text" name="poStatus"><br>
  96. poDate <input type="text" name="poDate"><br>
  97. expDate <input type="text" name="expDate"><br><br>
  98. <h4> Product Details</h4>
  99. <input type="button" onclick="appendtable()" value="Add Product">
  100. <div id="divide"></div>
  101. <input type="hidden" name='pId' id="pId">
  102. <input type="hidden" name='pName' id="pName">
  103. <input type="hidden" name='price' id="price">
  104. <input type="hidden" name='pQty' id="pQty">
  105. <input type="hidden" name='SKU' id="SKU">
  106. <input type="hidden" name='UPC' id="UPC">
  107. <br> <input type="submit" name="btnSubmit" value="Submit Order">
  108. </form>
  109. </body>
  110. </html>
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Urgent.....Dynamic Changes....

 
0
  #13
May 4th, 2005
I think the problem is my understanding of what you want to achieve. I don't see any problem with the result, from what I understand you are trying to do. Of course I can see why this would make any sense.

Oh and there is no reason to include a taglib here, your not using any JSP elements that I noticed...

Cheers,
alpha_foobar
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 14
Reputation: nandoo is an unknown quantity at this point 
Solved Threads: 0
nandoo nandoo is offline Offline
Newbie Poster

Re: Urgent.....Dynamic Changes....

 
0
  #14
May 4th, 2005
foo,

Once again i will xplain the scenario.
i m working in business to bussiness integration tool.we just need the jsp form to get the user input and assign the retrived values into the integraion tool.
for that i need a purchase order format page,which should have the
purchase order header:
purchase-order_id
senderID
receiverID
postatus
podate
expdate

purchase order detail:
productID
productName
productPrice
productQuantity
productSKU
productUPC

the purchase order detail should be generated according to the user needs.
for example
if the user wants 2 product items to be purchased then the detail should generated as follows
productID 1
productName product1
productPrice 89
productQuantity 9
productSKU 678
productUPC 465

productID 2
productName product2
productPrice 890
productQuantity 49
productSKU 6738
productUPC 4635
but the purchase order header should be unique for both the product

purchase-order_id 123
senderID x
receiverID y
postatus open
podate 7/08/2005
expdate 9/08/2005
i dont know the number of items the user is going to order
for that reason i used DOM for dynamic field generation

is there any solution for this problem
please give me the solution

thanks a lot foo..
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Urgent.....Dynamic Changes....

 
0
  #15
May 4th, 2005
well, if you looked at the output forwarded to you, you would see that all the dynamically created dom objects send you a value. This value is an array if more that one field with the same name exist.

which is why I don't understand why you'd want to assign the value to your hidden fields... especially not in a manner where it is the last row a user selects that is associated (this seems to be of little use apart from an excellent way of showing how to traverse the DOM).

Here is the name value pairs I got from playing:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. SKU='product SKU 3'
  2. UPC='product UPC 3'
  3. btnSubmit='Submit Order'
  4. expDate=''
  5. pId=''
  6. pName='product name 3'
  7. pQty='product quantity 3'
  8. poDate=''
  9. poId=''
  10. poStatus=''
  11. price='product price 3'
  12. prname='product name 1','product name 2','product name 3'
  13. prprice='product price 1','product price 2','product price 3'
  14. prqty='product quantity 1','product quantity 2','product quantity 3'
  15. prsku='product SKU 1','product SKU 2','product SKU 3'
  16. prupc='product UPC 1','product UPC 2','product UPC 3'
  17. senderAddress=''
  18. vendorAddress=''

Now do you see my point? You haven't shown me any good reason for the hidden fields (yet).
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 14
Reputation: nandoo is an unknown quantity at this point 
Solved Threads: 0
nandoo nandoo is offline Offline
Newbie Poster

Re: Urgent.....Dynamic Changes....

 
0
  #16
May 5th, 2005
yes foo

there is no need for hidden fields i have changed a code a littile bit and its working properly now.Thank you very much for your help.here is my code
sorry here is our code

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.  
  19. var oOption = document.createElement("option");
  20. var t0 = document.createTextNode("Ferrari");
  21. oOption.setAttribute("value", 0);
  22. oOption.appendChild(t0);
  23. oSelect.appendChild(oOption);
  24.  
  25. var oOption1 = document.createElement("option");
  26. var t1 = document.createTextNode("Fessari");
  27. oOption1.setAttribute("value", 1);
  28. oOption1.appendChild(t1);
  29. oSelect.appendChild(oOption1);
  30.  
  31. var prodId=document.createElement("input");
  32. prodId.type="hidden";
  33. prodId.value="product Id";
  34. prodId.name="pId";
  35.  
  36. var prodname=document.createElement("input");
  37. prodname.type="text";
  38. prodname.value="product name";
  39. prodname.name = "pName";
  40.  
  41. var prodprice=document.createElement("input");
  42. prodprice.type="text";
  43. prodprice.value="product price";
  44. prodprice.name="price";
  45.  
  46. var prodqty=document.createElement("input");
  47. prodqty.type="text";
  48. prodqty.value="product quantity";
  49. prodqty.name="pQty";
  50.  
  51. var prodsku=document.createElement("input");
  52. prodsku.type="text";
  53. prodsku.value="product SKU";
  54. prodsku.name="SKU";
  55.  
  56. var produpc=document.createElement("input");
  57. produpc.type="text";
  58. produpc.value="product UPC";
  59. produpc.name="UPC";
  60.  
  61. td.appendChild(prodId);
  62. td.appendChild(oSelect);
  63. td.appendChild(prodname);
  64. td.appendChild(prodprice);
  65. td.appendChild(prodsku);
  66. td.appendChild(produpc);
  67. oSelect.onchange=function(){ txtChange(this,prodname,prodprice,prodsku,produpc,prodId); }
  68. td.appendChild(prodqty);
  69.  
  70. }
  71.  
  72. function txtChange(obj,prname,prprice,prsku,prupc,prId)
  73. {
  74. var val=obj.selectedIndex;
  75. if (val==0)
  76. {
  77.  
  78. prId.value=val;
  79. prname.value=obj[val].text;
  80. prprice.value="2";
  81. prsku.value="90";
  82. prupc.value="70";
  83.  
  84. }
  85. else
  86. {
  87. prId.value=val;
  88. prname.value=obj[val].text;
  89. prprice.value="23";
  90. prsku.value="903";
  91. prupc.value="703";
  92. }
  93.  
  94.  
  95. }
  96.  
  97. </script>
  98. </head>
  99. <body bgcolor=black>
  100. <%@ taglib uri="http://webm-taglib.tld" prefix="webm" %>
  101. <FORM ACTION=http://10.200.13.83:5555/invoke/app/chkapp METHOD=POST>
  102.  
  103. <font color="#C12283"><h4>
  104. <pre>
  105. Purchase Order ID <input type="text" name="poId"><br>
  106. Sendor Address <input type="text" name="senderAddress"><br>
  107. Vendor Address <input type="text" name="vendorAddress"><br>
  108. poStatus <input type="text" name="poStatus"><br>
  109. poDate <input type="text" name="poDate"><br>
  110. expDate <input type="text" name="expDate"><br></pre><br>
  111. <h3> Product Details</h3>
  112.  
  113. <input type="button" onclick="appendtable()" value="Add Product"><br>
  114. <pre>
  115. <hr color=white>
  116. Product ID Product Name Product Price Product SKU Product UPC Product Quantity</pre>
  117. <div id="divide"></div>
  118. <hr color=white>
  119. <center>
  120. <br> <input type="submit" name="btnSubmit" value="Submit Order"></center>
  121. </font>
  122. </form>
  123.  
  124.  
  125. </body>
  126. </html>

now i am moving to next level.
yes i want the selection list option values to be generated from the result set of oracle database.
since the selection list was generated using dom would there be any problem.?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC