473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Multiple serials with multiple parts attached to it.

769 512MB
Hey Everyone,

Well i was hoping someone could explain the best way i could go about this.
i have a few ideas on how i could go about this but i am just not sure if it would work.

Right now i have a form where you can add and delete multiple serial information. This works wonderful. But now for every serial information i add i need to be able to add and remove multiple parts to that serial.

heres an example of what i mean

serial information 1
parts 1
parts 2

serial information 2
parts 1
parts 2

The thing is if one of the serial information's gets deleted all the parts associated with it also have to be able to be removed with it as well. So if anyone could explain the best way to do this i would very much appreciate it.Here is the code i currently have for it. This allows you to add multiple serials.

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to add serial information multiple times --->
  2. <script type="text/javascript">
  3. <!---Allows us to add multiple fields --->
  4. function addInput(divName){
  5. var dynamic = document.getElementById('dynamicInput');
  6. var thevalue = document.getElementById('theValue');
  7. var count = (document.getElementById('theValue').value -1)+ 2;
  8. thevalue.value = count;
  9. var newdiv = document.createElement('div');
  10. var divIdName = 'dynamic'+count+'Input';
  11. newdiv.setAttribute('id',divIdName);
  12.  
  13. <!--- Adds Extra fields for Model No, Product Type, and Type of Hardware Failure  --->
  14. newdiv.innerHTML =
  15. "<table class='zpExpandedTable' id='modeltable'>" +
  16. "<th class='sectiontitletick' colspan='7'>Serial Information "+ count +" </th>" +
  17. "<tr>" +
  18. "<td id='paddingformultitop'>Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>" +
  19. "</td>" +
  20. "<td>" +
  21.  "<select name='modelno_" + count + "' >" +
  22.  "<option value=''>Make A Selection</option>" +
  23. "<cfoutput query='models'>" + 
  24. "<option value='#model#'>#model#</option>" + 
  25. "</cfoutput>" + 
  26.  "</select>" +
  27.  "</td>" +
  28.  "<td>" +
  29. "&nbsp;&nbsp;&nbsp;&nbsp;Product Type:"  +
  30. "</td>" +
  31. "<td>" +
  32. "<select name='producttype_" + count + "'>" +
  33. "<option value='' selected>No Choice</option>" +
  34. "<cfoutput query='getProdType'>" + 
  35. "<option value='#pk_productType#'>#pk_productType#</option>" + 
  36. "</cfoutput>" + 
  37. "</select>" +
  38. "</td>" +
  39. "<td class='red'>" +
  40. "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:" +
  41. "</td>" +
  42. "<td>" +
  43. "<select name='hardwarefailure_" + count + "'>" +
  44. "<option value='' selected>Make A Selection</option>" +
  45. "<cfoutput query='getHardwareFail'>" +
  46. "<option value='#pk_hardwareFailure#'>#pk_hardwareFailure#</option>" +
  47. "</cfoutput>" +
  48. "</select>" +
  49. "</td>" +
  50. "</tr>" +
  51. "<table>";
  52.  
  53. <!--- Adds Extra fields for Serial Number and Software/Hardware  --->
  54. newdiv.innerHTML = newdiv.innerHTML +
  55. "<table class='zpExpandedTable' id='modeltable'>" +
  56. "<tr>" +
  57. "<td id='paddingformultitop'>" +
  58. "Serial Number:&nbsp;&nbsp;" +
  59. "<input type='text' name='serialnum_" + count + "'>" +
  60. "&nbsp;&nbsp;&nbsp;&nbsp;Software/Hardware:&nbsp;&nbsp;" +
  61. "<select name='softhardware_" + count + "'>" +
  62. "<option value='' selected>No Choice</option>" +
  63. "<cfoutput query='getSoftHard'>" + 
  64. "<option value='#pk_softwareHardware#'>#pk_softwareHardware#</option>" + 
  65. "</cfoutput>" + 
  66. "</select>" +
  67. "</td>" +
  68. "</tr>" +
  69. "</table>";
  70.  
  71. <!--- Adds Extra fields for Description  --->
  72. newdiv.innerHTML = newdiv.innerHTML + 
  73. "<table class='zpExpandedTable' id='resoltable' cellpadding='3' cellspacing='0'>" +
  74. "<tr>" +
  75. "<td id='paddingformutli'>" +
  76. "Description:&nbsp;&nbsp;" + 
  77. "</td>" +
  78. "<td class='descriptionmoveinmulti'>" +
  79. "( You may enter up to 1000 characters. )"+
  80. "<br>" +
  81. "<textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name='thedescription_" + count + "'></textarea>" +
  82. "</td>" +
  83. "</tr>" +
  84. "</table>";
  85.  
  86. <!--- Adds Extra fields for Resolution  --->
  87. newdiv.innerHTML = newdiv.innerHTML +
  88. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  89. "<tr>" +
  90. "<td id='paddingformutli'>" +
  91. "Resolution:&nbsp;&nbsp;" +
  92. "</td>" +
  93. "<td class='resolutionmoveinmulti'>" +
  94. "( You may enter up to 1500 characters. )"+
  95. "<br>" +
  96. "<textarea maxlength='1500' onkeyup='return resolutionmaxlength(this)' onkeydown='return resolutionmaxlength(this)' rows='4' cols='60' name='resolution_" + count + "'></textarea>" +
  97. "</td>" +
  98. "</tr>" +
  99. "</table>";
  100.  
  101. <!--- Adds Extra fields for Resolution Date, Current Date (for resolution date) and resolution vertified as effective by  --->
  102. newdiv.innerHTML = newdiv.innerHTML +
  103. "<table class='zpExpandedTable' id='resoldatetab' cellpadding='1' cellspacing='0'>" +
  104. "<tr>" +
  105. "<td id='paddingformultitop'>" +
  106. "Resolution Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;" +
  107. "</td>" +
  108. "<td>" +
  109. "<input type='text' name='resdate_" + count + "' value=''  >&nbsp;&nbsp;" +
  110.  
  111. "&nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;" +
  112. "<input type='checkbox' name='currentdateresol_" + count + "' onClick=resdate_" + count + ".value=fill_date()>" +
  113. "</td>" +
  114. "<td>" +
  115. "Resolution Verified as effective by:&nbsp;&nbsp;"  +
  116. "</td>" +
  117. "<td>" +
  118. "<select name='resvertified_" + count + "'>" +
  119. "<option value='' selected>Make A Selection</option>" +
  120. "<cfoutput query='gettech'><option value='#fname# #lname#'>#fname# #lname#</option></cfoutput>" +
  121. "</select>" +
  122. "</td>" +
  123. "</tr>" +
  124. "</table>";
  125.  
  126. <!--- Adds Extra fields for Vertification Date, Current Date (for vertification date) and resolution vertified as effective by  --->
  127. newdiv.innerHTML = newdiv.innerHTML +
  128. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  129. "<tr>" +
  130. "<td id='paddingformultitop'>" +
  131. "Verification Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;" +
  132. "</td>" +
  133. "<td class='vertificationmoveinmulti'>" +
  134. "<input type='text' name='vertifidate_" + count + "'>&nbsp;&nbsp;" +
  135. "&nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;" +
  136. "<input type='checkbox' name='currentdatevert_" + count + "' onClick=vertifidate_" + count + ".value=fill_date()>" +
  137. "</td>" +
  138. "</tr>" +
  139. "</table>";
  140.  
  141. <!--- Adds Extra fields for Dept/Vendor Responsibility  --->
  142. newdiv.innerHTML = newdiv.innerHTML +
  143. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  144. "<tr>" +
  145. "<td class='red' id='paddingformultitop'>" +
  146. "Dept/Vendor Responsibility*:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"  +
  147. "<select name='deptvendor_" + count + "'>" +
  148. "<option value='' selected>Make A Selection</option>" +
  149. "<cfoutput query='getDeptVendor'>" +
  150. "<option value='#pk_deptVendor#'>#pk_deptVendor#</option>" +
  151. " </cfoutput>" +
  152. "</select>" +
  153. "</td>" +
  154. "</tr>" +
  155. "</table>";
  156.  
  157. <!--- Adds Extra fields for RMA Data Only  --->
  158. newdiv.innerHTML = newdiv.innerHTML +
  159. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  160. "<tr>" +
  161. "<td id='paddingformultitop'>" +
  162. "RMA Data Only:&nbsp;&nbsp;&nbsp;&nbsp;" +
  163. "</td>" +
  164. "<td class='rmanmoveinmulti'>" +
  165. "( You may enter up to 1000 characters. )"+
  166. "<br/>" +
  167. "<textarea maxlength='1000' onkeyup='return rmamaxlength(this)' onkeydown='return rmamaxlength(this)' rows='4' cols='60' name='rma_" + count + "'></textarea> " +
  168. "</td>" +
  169. "</tr>" +
  170. "</table>" +
  171. "<input type='hidden' name='serialcount' value='" + count + "'>";
  172.  
  173. <!--- Adds Delete to every ticket  --->
  174. newdiv.innerHTML = newdiv.innerHTML +
  175. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  176. "<tr>" +
  177. "<td>" +
  178. "<input type='button' class='removeticket' value='Remove Serial &quot;"+count +"&quot;' onclick=\"removeElement(\'"+divIdName+"\')\"></a>" +
  179. "</td>" +
  180. "</td>" +
  181. "</tr>" +
  182. "</table>";
  183.  
  184. document.getElementById(divName).appendChild(newdiv);
  185.  
  186. <!---Allows us to remove multiple fields --->
  187. function removeElement(divNum) {
  188.   var d = document.getElementById('dynamicInput');
  189.   var olddiv = document.getElementById(divNum);
  190.   d.removeChild(olddiv);
  191. }
  192. </script>
  193.  
  194. <form>
  195. <!--- Ticket Information --->
  196. <input type="hidden" value="0" id="theValue" />
  197.      <div id="dynamicInput">
  198.      <!--- All Ticket Information Appears Here--->
  199.      </div>
  200.      <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
  201.      </form>

Thank you in advance,
Rach
Oct 7 '08
92 4576
acoder
16,027 Expert Mod 8TB
It needs to be partc, the variable, not "partc", the string, e.g.
Expand|Select|Wrap|Line Numbers
  1. id='"+partc+"' \>"
Oct 10 '08 #51
bonneylake
769 512MB
It needs to be partc, the variable, not "partc", the string, e.g.
Expand|Select|Wrap|Line Numbers
  1. id='"+partc+"' \>"
Hey Acoder,

This is what i have for it now

Expand|Select|Wrap|Line Numbers
  1. <input type='hidden' value='0' id='+partc+' \>
Thank you,
Rach
Oct 10 '08 #52
acoder
16,027 Expert Mod 8TB
Don't forget to quote properly.

Next, you need to get this element in addpartInput(). So you can parse the ID of the serial (passed as partName) to get the count to construct the ID required. You could do that by removing the "dynamic" and "Input" parts to get a number.
Oct 10 '08 #53
bonneylake
769 512MB
Don't forget to quote properly.

Next, you need to get this element in addpartInput(). So you can parse the ID of the serial (passed as partName) to get the count to construct the ID required. You could do that by removing the "dynamic" and "Input" parts to get a number.
Hey Acoder,

I am lost by this part.

Would i get it by doing
Expand|Select|Wrap|Line Numbers
  1. var get = document.getElementById('partc');
or instead of partc do '"+partc+"'?

an not sure which dynamic an input you mean to remove are you talking
about the one in the remove multiple fields section of parts?

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields --->
  2. function removeElement(divNum) {
  3.   var d = document.getElementById('dynamicInput');
  4.   var olddiv = document.getElementById(divNum);
  5.   d.removeChild(olddiv);
  6. }
Thank you,
Rach
Oct 10 '08 #54
acoder
16,027 Expert Mod 8TB
You need to construct the ID in addpartInput. Now the ID is "partscount" + a number. This number if you notice is the same number as the one in the ID of the serial div "dynamic1Input", "dynamic2Input". So what you need to do is take the variable that holds this string (passed in as partName) and parse it to get the number. Do you understand so far?

Now to get this number, what I'm suggesting is to remove the "dynamic" and "Input" from the string and you have the number that you need which you can use to get the id that you need to get the parts div element. Still following? There are other ways, but this one is one possible way.
Oct 11 '08 #55
bonneylake
769 512MB
Hey Acoder,

How would i parse it to get the number? not sure how to do that

an i am confused on the remove dynamic and input. The reason i am confused is because it appears so many times in the code that i got no clue which one needs to go an stay and the only one i can think your talking about removing is
Expand|Select|Wrap|Line Numbers
  1. var divIdName = 'dynamic'+count+'Input';
because other wise i have no clue because dynamic appears in many places which is why i am getting confused because there is so many different ones.

theres the 2 dynamic inputs that appear in the serial function

Expand|Select|Wrap|Line Numbers
  1. function addInput(divName){
  2. var dynamic = document.getElementById('dynamicInput');
  3. var thevalue = document.getElementById('theValue');
  4. var count = (document.getElementById('theValue').value -1)+ 2;
  5. thevalue.value = count;
  6. var newdiv = document.createElement('div');
  7. var getparts = document.createElement('div');
  8. var divIdName = 'dynamic'+count+'Input';
  9. var partc = 'partscount'+count;
  10. newdiv.setAttribute('id',divIdName);
theres the one for remove

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields --->
  2. function removeElement(divNum) {
  3.   var d = document.getElementById('dynamicInput');
  4.   var olddiv = document.getElementById(divNum);
  5.   d.removeChild(olddiv);
  6. }
theres the 2 that appear for the body
Expand|Select|Wrap|Line Numbers
  1. <body onload="addInput('dynamicInput');addpartInput('dynamic1Input');">
and the one that appears in the html
Expand|Select|Wrap|Line Numbers
  1. !--- Ticket Information --->
  2. <input type="hidden" value="0" id="theValue" />
  3. <input type="hidden" value="0" id="aValue" />
  4.      <div id="dynamicInput">
  5.  
  6.      </div>
  7.     <!---      <div id="partsInput">   </div>--->
  8. <!---      All Ticket Information Appears Here--->
  9.  
  10.  
  11.      <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
Thank you,
Rach
Oct 11 '08 #56
acoder
16,027 Expert Mod 8TB
I don't mean to remove it from the actual code. You need to add code to take the the string passed into the addpartInput function and convert it into a number. You can use the String replace() method, e.g.
Expand|Select|Wrap|Line Numbers
  1. serialno = partName.replace("dynamic","").replace("Input","");
then you can append it to "partscount" to get the id.
Oct 11 '08 #57
bonneylake
769 512MB
Hey Acoder,

i added the string into the parts function.

Expand|Select|Wrap|Line Numbers
  1. <!---Adds multiple fields for parts --->
  2. function addpartInput(partName){
  3. var parts = document.getElementById(partName);
  4. var getparts = document.getElementById('div');
  5. var avalue = document.getElementById('aValue');
  6. var count = (document.getElementById('aValue').value -1)+ 2;
  7. avalue.value = count;
  8. var partdiv = document.createElement('div');
  9. var partIdName = 'part'+count+'Name';
  10. var serialno = partName.replace("dynamic","").replace("Input","");
  11. partdiv.setAttribute('id',partIdName);
but do i append it in the parts function like so

Expand|Select|Wrap|Line Numbers
  1. document.getElementById(partName).appendChild(partdiv).appendChild(serialno);
Thank you,
Rach
Oct 11 '08 #58
acoder
16,027 Expert Mod 8TB
No, not that kind of append. I mean string concatenation where you add it to "partscount". This ID would then replace "aValue" in line 5 in your last post.
Oct 12 '08 #59
bonneylake
769 512MB
Hey Acoder,

so your saying to take this line out
Expand|Select|Wrap|Line Numbers
  1. var avalue = document.getElementById('aValue');
and replace it with

Expand|Select|Wrap|Line Numbers
  1. var serialno = partName.replace("dynamic","").replace("Input","");
an then whats next?

Thank you :),
Rach
Oct 12 '08 #60
acoder
16,027 Expert Mod 8TB
Obviously, that's not enough. It has to be an adequate replacement. The first line gets an element, so the replacement must do the same. So construct the string as I explained earlier and then pass it to document.getElementById().
Oct 13 '08 #61
bonneylake
769 512MB
Obviously, that's not enough. It has to be an adequate replacement. The first line gets an element, so the replacement must do the same. So construct the string as I explained earlier and then pass it to document.getElementById().
Hey Acoder,

I am sorry i am still very confused. Are you saying to do something like

Expand|Select|Wrap|Line Numbers
  1. var replacevalue= document.getElementById(serialno);
  2.  
and then do the below?

Expand|Select|Wrap|Line Numbers
  1. var serialno = partName.replace("dynamic","").replace("Input","");
an then do i need to take out the below from the parts function?

Expand|Select|Wrap|Line Numbers
  1. var avalue = document.getElementById('aValue'); 
  2.  
Thank you,
Rach
Oct 13 '08 #62
acoder
16,027 Expert Mod 8TB
You can keep the line and just change the "aValue" string which needs to be the ID of the new element, "partscount"+serialno.
Oct 13 '08 #63
bonneylake
769 512MB
You can keep the line and just change the "aValue" string which needs to be the ID of the new element, "partscount"+serialno.
Hey Acoder,

So the line should be this correct?

Expand|Select|Wrap|Line Numbers
  1. var avalue = document.getElementById('partc');
an then do you want me to do the other 2 parts i mentioned above this line the ones about the serialno?

Thank you,
Rach
Oct 13 '08 #64
acoder
16,027 Expert Mod 8TB
No, this should be in addpartInput() and not set to "partc" which, if I'm not mistaken, probably doesn't exist. It should literally be set to "partscount"+serialno.
Oct 13 '08 #65
bonneylake
769 512MB
No, this should be in addpartInput() and not set to "partc" which, if I'm not mistaken, probably doesn't exist. It should literally be set to "partscount"+serialno.
Hey Acoder,

well i think i have it all wrong so i going to show you what i got because i think i got it all upside down. Here is what i have for both functions.


Expand|Select|Wrap|Line Numbers
  1. <!---serial function --->
  2. function addInput(divName){
  3. var dynamic = document.getElementById('dynamicInput');
  4. var thevalue = document.getElementById('theValue');
  5. var count = (document.getElementById('theValue').value -1)+ 2;
  6. thevalue.value = count;
  7. var newdiv = document.createElement('div');
  8. var getparts = document.createElement('div');
  9. var divIdName = 'dynamic'+count+'Input';
  10. var partc = 'partscount'+count;
  11.  
  12. newdiv.setAttribute('id',divIdName);
  13.  
Expand|Select|Wrap|Line Numbers
  1. <!---parts function --->
  2. function addpartInput(partName){
  3. var parts = document.getElementById(partName);
  4. var getparts = document.getElementById('div');
  5. var avalue = document.getElementById('aValue');
  6. var avalue = document.getElementById('"partscount"+serialno');
  7. var count = (document.getElementById('aValue').value -1)+ 2;
  8. avalue.value = count;
  9. var partdiv = document.createElement('div');
  10. var partIdName = 'part'+count+'Name';
  11. var serialno = partName.replace("dynamic","").replace("Input","");
  12.  
  13. partdiv.setAttribute('id',partIdName);
  14.  
Thank you,
Rach
Oct 13 '08 #66
acoder
16,027 Expert Mod 8TB
If you put "partscount"+serialno in quotes, then it'll be treated as a string whcih is what you don't want. On top of that, if you're setting serialno afterwards (on line 11), it won't be available on line 6. Line 5 wouldn't be needed any longer. On line 7, you're not making use of the avalue variable which you should be in place of document.getElementById("aValue").

I think either I'm not explaining well or you haven't understood what I've been trying to say. The idea was simple: change the ID to the new hidden element(s) instead of the old one.
Oct 13 '08 #67
bonneylake
769 512MB
Hey Acoder,

Your explaining good i am just not understanding. Mostly getting confused because there is 2 of them an so its hard to keep them straight. Also, i am not best at the terminology of JavaScript so i often get thrown off by the word string or variable. although i have read up on JavaScript and looked at examples and understood what i read and the examples, its hard for me to apply it to what i am working on. An i also been sick last few days so i haven't been able to fully focus either. So your doing a good job :), just me being slow which i am sorry i am being slow on this. But anyway i understood everything except the part about line 7 does the aValue that appear in this line
Expand|Select|Wrap|Line Numbers
  1. var count = (document.getElementById('aValue').value -1)+ 2;
need to be changed to

Expand|Select|Wrap|Line Numbers
  1. var count = (document.getElementById('avalue').value -1)+ 2;
Here is the parts function with everything else added

Expand|Select|Wrap|Line Numbers
  1. <!---parts function--->
  2. function addpartInput(partName){
  3. var parts = document.getElementById(partName);
  4. var getparts = document.getElementById('div');
  5. var avalue = document.getElementById("partscount"+serialno);
  6. var serialno = partName.replace("dynamic","").replace("Input","");
  7. var count = (document.getElementById('aValue').value -1)+ 2;
  8. avalue.value = count;
  9. var partdiv = document.createElement('div');
  10. var partIdName = 'part'+count+'Name';
  11.  
  12. partdiv.setAttribute('id',partIdName);
Thank you,
Rach
Oct 13 '08 #68
acoder
16,027 Expert Mod 8TB
Almost there. Lines 5 and 6 need to be swapped around otherwise serialno won't be set when you use it (resulting in an error). Secondly, you need to replace the document.getElementById() on line 7 to this new variable (which would be set to an element) to make use of it.
Oct 13 '08 #69
bonneylake
769 512MB
Almost there. Lines 5 and 6 need to be swapped around otherwise serialno won't be set when you use it (resulting in an error). Secondly, you need to replace the document.getElementById() on line 7 to this new variable (which would be set to an element) to make use of it.
Hey Acoder,

here is what i got. I think i might of done the part about line 7 wrong does it need to be set to avalue or to serialno?
Expand|Select|Wrap|Line Numbers
  1. <!---parts function--->
  2. function addpartInput(partName){
  3. var parts = document.getElementById(partName);
  4. var getparts = document.getElementById('div');
  5. var serialno = partName.replace("dynamic","").replace("Input","");
  6. var avalue = document.getElementById("partscount"+serialno);
  7. var count = (document.getElementById('avalue').value -1)+ 2;
  8. avalue.value = count;
  9. var partdiv = document.createElement('div');
  10. var partIdName = 'part'+count+'Name';
  11.  
  12. partdiv.setAttribute('id',partIdName);
Thank you,
Rach
Oct 13 '08 #70
acoder
16,027 Expert Mod 8TB
avalue is already an element, not a string, so document.getElementById() is not required in that line.
Oct 13 '08 #71
bonneylake
769 512MB
avalue is already an element, not a string, so document.getElementById() is not required in that line.
Hey Acoder,

So leave line 7 like this

Expand|Select|Wrap|Line Numbers
  1. var count = (value -1)+ 2;
Thank you,
Rach
Oct 13 '08 #72
acoder
16,027 Expert Mod 8TB
I'd personally use something like:
Expand|Select|Wrap|Line Numbers
  1. var count = parseInt(avalue.value) + 1;
Oct 13 '08 #73
bonneylake
769 512MB
I'd personally use something like:
Expand|Select|Wrap|Line Numbers
  1. var count = parseInt(avalue.value) + 1;
Hey Acoder,

Here is what i have

Expand|Select|Wrap|Line Numbers
  1. <!---parts function --->
  2. function addpartInput(partName){
  3. var parts = document.getElementById(partName);
  4. var getparts = document.getElementById('div');
  5. var serialno = partName.replace("dynamic","").replace("Input","");
  6. var avalue = document.getElementById("partscount"+serialno);
  7. var count = parseInt(avalue.value) + 1;
  8. avalue.value = count;
  9. var partdiv = document.createElement('div');
  10. var partIdName = 'part'+count+'Name';
  11.  
  12.  
  13. partdiv.setAttribute('id',partIdName);
an i tested out an its numbering correctly (serial information 1 parts 1 parts 2, serial information 2 parts 1 parts 2) an i only see one problem. its a hard one to explain. But basically if i add 2 parts under each serial (an i add 2 serials) . if i go to delete them all except 1 i am having the problem of it puts parts under the last serial.

example

serial information 1
test 1 (parts)
test2 (parts)

serial information 2
test 3 (parts)
test 4 (parts)

if i delete all except test 2. Instead of it remaining under serial information 1 it appears under serial information 2. Basically instead of the part remaining under the serial i added it with, its putting it under a different serial once i remove a part i added. An it happens with any part i add. Any ideas?

Thank you,
Rach
Oct 13 '08 #74
acoder
16,027 Expert Mod 8TB
It seems the part div ID is not unique. Try adding the serial no. to it to make it unique, e.g.
Expand|Select|Wrap|Line Numbers
  1. var partIdName = 'part' + count + 'Name' + serialno;
Oct 14 '08 #75
bonneylake
769 512MB
It seems the part div ID is not unique. Try adding the serial no. to it to make it unique, e.g.
Expand|Select|Wrap|Line Numbers
  1. var partIdName = 'part' + count + 'Name' + serialno;

Hey Acoder,

Yep that was it.Thank you, Thank you!!! So heres the whole parts section done.

Expand|Select|Wrap|Line Numbers
  1. function addpartInput(partName){
  2. var parts = document.getElementById(partName);
  3. var getparts = document.getElementById('div');
  4. var serialno = partName.replace("dynamic","").replace("Input","");
  5. var avalue = document.getElementById("partscount"+serialno);
  6. var count = parseInt(avalue.value) + 1;
  7. avalue.value = count;
  8. var partdiv = document.createElement('div');
  9. var partIdName = 'part' + count + 'Name' + serialno;
  10.  
  11. partdiv.setAttribute('id',partIdName);
But anyway i was wondering. I talked to you about this earlier, but we had gotten on to another topic. How would make it so each part said this

part 1 serial information 1

basically so the user wont get confused because there will be a good amount of serials and parts being added an just want them to know what part goes with what serial.

Thank you,
Rach
Oct 14 '08 #76
acoder
16,027 Expert Mod 8TB
I notice you have this line:
Expand|Select|Wrap|Line Numbers
  1. "<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information <div id='dynamicInput'></div></th>" +
I'm not sure why you have that dynamicInput div in there - remove it and put the serialno variable in there (like count) and you should be good to go.
Oct 14 '08 #77
bonneylake
769 512MB
Hey Acoder,

I got just one more question an i should be able to figure out the rest "i hope". I am having trouble inserting the parts into the table. This is what i been trying

Expand|Select|Wrap|Line Numbers
  1. <!---Inserts information into serial table.--->
  2. <CFIF REQUEST_METHOD EQ "POST">
  3. <CFSET machineListLen = listLen(Form.serialcount)>
  4. <CFLOOP from="1" to="#machineListLen#" index="machineCount">
  5.  <CFSET serialnum       = Form["serialnum_" & machineCount]>
  6.  <CFSET modelno         = Form["modelno_" & machineCount]>
  7.  <CFSET producttype     = Form["producttype_" & machineCount]>
  8.  <CFSET softhardware    = Form["softhardware_" & machineCount]>
  9.  <CFSET resolution      = Form["resolution_" & machineCount]>
  10.  <CFSET resdate         = Form["resdate_" & machineCount]>
  11.  <CFSET resvertified    = Form["resvertified_" & machineCount]>
  12.  <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
  13.  <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
  14.  <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
  15.  <CFSET rma             = Form["rma_" & machineCount]>
  16.  <CFSET thedescription  = Form["thedescription_" & machineCount]>
  17.  <CFSET hcpn            = Form["hcpn_" & machineCount]>
  18.  <CFSET partsreturn     = Form["partsreturn_" & machineCount]>
  19.  <CFSET defective       = Form["defective_" & machineCount]>
  20. <!--- <CFSET followdate      = Form["followdate_" & machineCount]>
  21.  <CFSET onsite          = Form["onsite_" & machineCount]>
  22.  <CFSET numonsite       = Form["numonsite_" & machineCount]>--->
  23.  
  24. <cfquery name="serial" datasource="CustomerSupport">
  25.    exec usp_CS_Insertserial 
  26.      <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  27.      '#Form.ID#',
  28.      <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
  29.      <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
  30.      <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
  31.      <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
  32.      <cfqueryparam value="#resdate#">,
  33.      <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
  34.      <cfqueryparam value="#vertifidate#">,
  35.      <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
  36.      <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">,
  37.      <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  38.    </cfquery>
  39.  
  40. <!---Inserts information into notes_descr table.--->
  41. <cfquery name="description" datasource="CustomerSupport">
  42.     exec usp_CS_Insertdescription
  43.    <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  44.    '#Form.ID#',
  45.    <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
  46.    '#Form.fk_addedBy#'
  47. </cfquery>
  48.  
  49. <!---Inserts parts information into parts table.--->
  50. <!---because it is a bit we don't use 'ticks' around defective for parts table--->
  51. <cfquery name="parts" datasource="CustomerSupport">
  52.     exec usp_CS_Insertparts 
  53.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  54.     '#Form.ID#',
  55.     <cfquery param value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  56.     <cfquery param value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  57.     <cfquery param value="#defective#" CFSQLType = "CF_SQL_VARCHAR">,
  58. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  59. </cfquery>
  60.  
  61. </CFLOOP>
  62. </CFIF>
and i get the error Just in time compilation error.An unknown attribute 'param' has been encountered. An it says it happens right in the insert parts information. An well was wondering. In the serial function i had this line at the end

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='serialcount' value='" + count + "'>";
do i need to add this line into parts? or do i need to create something else?

Thank you,
Rach
Oct 14 '08 #78
acoder
16,027 Expert Mod 8TB
This is a Coldfusion problem. The cfqueryparam tags have a space between them.
Oct 14 '08 #79
bonneylake
769 512MB
This is a Coldfusion problem. The cfqueryparam tags have a space between them.
Hey Acoder,

Yeah i know its a coldfusion problem. But wanted to make sure this line

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='serialcount' value='" + count + "'>";
was not causing the trouble before having to start a new thread. Do i need this line in both the serial function and the parts function to make it insert correctly?

Thank you,
Rach
Oct 14 '08 #80
acoder
16,027 Expert Mod 8TB
I doubt it from what I can see from the query, so I would suggest a new thread.
Oct 14 '08 #81
bonneylake
769 512MB
I doubt it from what I can see from the query, so I would suggest a new thread.
Hey Acoder,

But do i need this line in the serial and parts function or just the serial function because right now have it in both

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='serialcount' value='" + count + "'>";
but started a new thread which here is the link

http://bytes.com/forum/showthread.ph...82#post3387382

But thank you again for all the help i really appreciate it, its awesome to see it working! Thank you Thank you!!!!!

Thank you again :),
Rach
Oct 14 '08 #82
acoder
16,027 Expert Mod 8TB
No, you wouldn't need that line in either function because you already have the counts, one for all serials and one each for parts in each serial.

And, of course, you're welcome!
Oct 14 '08 #83
bonneylake
769 512MB
No, you wouldn't need that line in either function because you already have the counts, one for all serials and one each for parts in each serial.

And, of course, you're welcome!
Hey Acoder,

Are you sure i don't need the line at all? because in my cold fusion it uses that field for the count

Expand|Select|Wrap|Line Numbers
  1. <CFIF REQUEST_METHOD EQ "POST">
  2. <CFSET machineListLen = listLen(Form.serialcount)>
  3. <CFLOOP from="1" to="#machineListLen#" index="machineCount">
Thank you,
Rach
Oct 14 '08 #84
acoder
16,027 Expert Mod 8TB
Well, OK, you do need it, but you only need one, not one each for each serial. The one you need is the one with ID "theValue". Give it the name "serialcount". Likewise for parts counts, give them names so that they can be used in Coldfusion.
Oct 14 '08 #85
bonneylake
769 512MB
Well, OK, you do need it, but you only need one, not one each for each serial. The one you need is the one with ID "theValue". Give it the name "serialcount". Likewise for parts counts, give them names so that they can be used in Coldfusion.
Hey Acoder,

So in the serial function put this

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='serialcount' value='" + count + "'>";
  2.  
  3. <!--- Adds Delete to every ticket  --->
  4. newdiv.innerHTML = newdiv.innerHTML +
an to the parts function do this

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='partscount' value='" + count + "'>";
  2.  
  3.  
  4. <!--- Adds Delete to every ticket  --->
  5. partdiv.innerHTML = partdiv.innerHTML +
correct?

Thank you,
Rach
Oct 14 '08 #86
acoder
16,027 Expert Mod 8TB
No, you don't need any extra ones. You already have them within your code, so there's no need to create redundant elements.

The ones I'm talking about are the ones you've been using in your JavaScript code. The element in the HTML for serials and the multiple parts counts created in addInput() for parts.
Oct 14 '08 #87
bonneylake
769 512MB
No, you don't need any extra ones. You already have them within your code, so there's no need to create redundant elements.

The ones I'm talking about are the ones you've been using in your JavaScript code. The element in the HTML for serials and the multiple parts counts created in addInput() for parts.
Hey Acoder,

Ok so saying to leave the one in serial function

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='serialcount'  id="theValue" value='" + count + "'>";
and then for the parts put

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='partc'  id="theValue" value='" + count + "'>";
Thank you,
Rach
Oct 14 '08 #88
acoder
16,027 Expert Mod 8TB
No, you don't need any more at all. You can just use the ones that you're already using: "theValue" in the HTML just above the "dynamicInput" div and "partscount1", "partscount2", etc. in the addInput function.
Oct 14 '08 #89
bonneylake
769 512MB
No, you don't need any more at all. You can just use the ones that you're already using: "theValue" in the HTML just above the "dynamicInput" div and "partscount1", "partscount2", etc. in the addInput function.
Hey Acoder,

Alrighty i understand now. Do i need to remove the other value i have in the html as well? these are the 2 i have in the html

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value="0" id="theValue" />
  2. <input type="hidden" value="0" id="aValue" />
Thank you,
Rach
Oct 14 '08 #90
acoder
16,027 Expert Mod 8TB
I don't think you'll need the "aValue" one, though you'll now need to name these hidden input fields so that they're also available to Coldfusion, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value="0" name="serialcount" id="theValue" />
Oct 14 '08 #91
bonneylake
769 512MB
I don't think you'll need the "aValue" one, though you'll now need to name these hidden input fields so that they're also available to Coldfusion, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value="0" name="serialcount" id="theValue" />
Hey Acoder,

am i going to be putting this field in the cfloop? or is this for good coldfusion practice?

here is what i have now

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value="0" id="theValue" name="theValue"/>
Thank you,
Rach
Oct 14 '08 #92
acoder
16,027 Expert Mod 8TB
Yes, you'll need the name for Coldfusion, not just for good practice, but uou have to be consistent in the naming, i.e. the names must match up: "serialcount" on both sides or "theValue".
Oct 14 '08 #93

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

Similar topics

0
by: PA | last post by:
Can anyone tell me how to write XDR schema for XML below: <?xml version="1.0"?> <bk:Book xmlns:bk="urn:BookSchema.xdr"> <a:title>Sam's Book</a:title> <a:author>Sam</a:author>...
1
by: Elf M. Sternberg | last post by:
This is driving me nuts. I don't want to have to do hokey Javascript magic to make it go away, so please, help me. I have a form with two SUBMIT buttons three lines of TEXT inputs... but pressing...
3
by: sql-db2-dba | last post by:
There are 2 tables A and B with A being the parent of B. Table A ( Col1 varchar(5) Not Null ) Table B ( B_PK varchar(5) Not Null ,
10
by: Rich Kucera | last post by:
Holding all versions at 5.0.4, Multiple stacks with multiple-version configurations inevitable Will have to wait to see what the impact of problems such as http://bugs.php.net/bug.php?id=33643 ...
3
by: | last post by:
I'm seeking (probably basic) guidance on the right way to split a large site that's supposed to represent one domain(mydomain.org) into many small VS.NET projects, and how to avoid issues with...
6
by: Jankie | last post by:
Hi all ! I hope someone help me with problem that I assume common,yet googling didnt even mention it. In brief: User uploads multiple files at one go. It is one submission of multiple files,so I...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
3
by: DragonLord | last post by:
Ok here is the situation in detail. Single form with multiple items on it, 4 of which are panls that contain radio butons. Each panel loads it's radio buttons from a list of items in a sql...
1
by: Lyn DeMaio | last post by:
I've been tasked with taking two unrealted tables (Providers and Patients, no common field) and allow users, on one form (or form/subform) to search multiple fields in each table, select a record...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.