469,301 Members | 2,278 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

displaying previously entered multiple fields

769 512MB
Hey Everyone,

Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place.

what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my parts fields correctly.

Currently this is what it does

serial information 1
parts 1
parts 2

serial information 2
parts 1
parts 2

and what it needs to do

serial information 1
parts 1
serial information 2
parts 1

the problem is instead of the part going with the correct serial. it basically puts the information for both parts i added under both of the 2 serials I am also having trouble deleting fields an adding fields for the parts fields.

if someone could explain what i am doing wrong with the parts i would really appreciate it. I know it has to do with the count, just not sure what i am doing wrong


here is the javascript for serial and parts that allows me to add serials and parts

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 getparts = document.createElement('div');
  11. var divIdName = 'dynamic'+count+'Input';
  12. var partc = 'partscount'+count;
  13.  
  14. newdiv.setAttribute('id',divIdName);
  15.  
  16. <!--- Adds Extra fields for Model No, Product Type, and Type of Hardware Failure  --->
  17. newdiv.innerHTML =
  18. "<table class='zpExpandedTable' id='modeltable'>" +
  19. "<th class='sectiontitletick' colspan='7'>Serial Information "+ count +" </th>" +
  20. "<tr>" +
  21. "<td id='paddingformultitop'>Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>" +
  22. "</td>" +
  23. "<td>" +
  24.  "<select name='modelno_" + count + "' >" +
  25.  "<option value=''>Make A Selection</option>" +
  26. "<cfoutput query='models'>" + 
  27. "<option value='#model#'>#model#</option>" + 
  28. "</cfoutput>" + 
  29.  "</select>" +
  30.  "</td>" +
  31.  "<td>" +
  32. "&nbsp;&nbsp;&nbsp;&nbsp;Product Type:"  +
  33. "</td>" +
  34. "<td>" +
  35. "<select name='producttype_" + count + "'>" +
  36. "<option value='' selected>No Choice</option>" +
  37. "<cfoutput query='getProdType'>" + 
  38. "<option value='#pk_productType#'>#pk_productType#</option>" + 
  39. "</cfoutput>" + 
  40. "</select>" +
  41. "</td>" +
  42. "<td class='red'>" +
  43. "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:" +
  44. "</td>" +
  45. "<td>" +
  46. "<select name='hardwarefailure_" + count + "'>" +
  47. "<option value='' selected>Make A Selection</option>" +
  48. "<cfoutput query='getHardwareFail'>" +
  49. "<option value='#pk_hardwareFailure#'>#pk_hardwareFailure#</option>" +
  50. "</cfoutput>" +
  51. "</select>" +
  52. "</td>" +
  53. "</tr>" +
  54. "<table>";
  55.  
  56. <!--- Adds Extra fields for Serial Number and Software/Hardware  --->
  57. newdiv.innerHTML = newdiv.innerHTML +
  58. "<table class='zpExpandedTable' id='modeltable'>" +
  59. "<tr>" +
  60. "<td id='paddingformultitop'>" +
  61. "Serial Number:&nbsp;&nbsp;" +
  62. "<input type='text' name='serialnum_" + count + "'>" +
  63. "&nbsp;&nbsp;&nbsp;&nbsp;Software/Hardware:&nbsp;&nbsp;" +
  64. "<select name='softhardware_" + count + "'>" +
  65. "<option value='' selected>No Choice</option>" +
  66. "<cfoutput query='getSoftHard'>" + 
  67. "<option value='#pk_softwareHardware#'>#pk_softwareHardware#</option>" + 
  68. "</cfoutput>" + 
  69. "</select>" +
  70. "</td>" +
  71. "</tr>" +
  72. "</table>";
  73.  
  74. <!--- Adds Extra fields for Description  --->
  75. newdiv.innerHTML = newdiv.innerHTML + 
  76. "<table class='zpExpandedTable' id='resoltable' cellpadding='3' cellspacing='0'>" +
  77. "<tr>" +
  78. "<td id='paddingformutli'>" +
  79. "Description:&nbsp;&nbsp;" + 
  80. "</td>" +
  81. "<td class='descriptionmoveinmulti'>" +
  82. "( You may enter up to 1000 characters. )"+
  83. "<br>" +
  84. "<textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name='thedescription_" + count + "'></textarea>" +
  85. "</td>" +
  86. "</tr>" +
  87. "</table>";
  88.  
  89. <!--- Adds Extra fields for Resolution  --->
  90. newdiv.innerHTML = newdiv.innerHTML +
  91. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  92. "<tr>" +
  93. "<td id='paddingformutli'>" +
  94. "Resolution:&nbsp;&nbsp;" +
  95. "</td>" +
  96. "<td class='resolutionmoveinmulti'>" +
  97. "( You may enter up to 1500 characters. )"+
  98. "<br>" +
  99. "<textarea maxlength='1500' onkeyup='return resolutionmaxlength(this)' onkeydown='return resolutionmaxlength(this)' rows='4' cols='60' name='resolution_" + count + "'></textarea>" +
  100. "</td>" +
  101. "</tr>" +
  102. "</table>";
  103.  
  104. <!--- Adds Extra fields for Resolution Date, Current Date (for resolution date) and resolution vertified as effective by  --->
  105. newdiv.innerHTML = newdiv.innerHTML +
  106. "<table class='zpExpandedTable' id='resoldatetab' cellpadding='1' cellspacing='0'>" +
  107. "<tr>" +
  108. "<td id='paddingformultitop'>" +
  109. "Resolution Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;" +
  110. "</td>" +
  111. "<td>" +
  112. "<input type='text' name='resdate_" + count + "' value=''  >&nbsp;&nbsp;" +
  113.  
  114. "&nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;" +
  115. "<input type='checkbox' name='currentdateresol_" + count + "' onClick=resdate_" + count + ".value=fill_date()>" +
  116. "</td>" +
  117. "<td>" +
  118. "Resolution Verified as effective by:&nbsp;&nbsp;"  +
  119. "</td>" +
  120. "<td>" +
  121. "<select name='resvertified_" + count + "'>" +
  122. "<option value='' selected>Make A Selection</option>" +
  123. "<cfoutput query='gettech'><option value='#fname# #lname#'>#fname# #lname#</option></cfoutput>" +
  124. "</select>" +
  125. "</td>" +
  126. "</tr>" +
  127. "</table>";
  128.  
  129. <!--- Adds Extra fields for Vertification Date, Current Date (for vertification date) and resolution vertified as effective by  --->
  130. newdiv.innerHTML = newdiv.innerHTML +
  131. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  132. "<tr>" +
  133. "<td id='paddingformultitop'>" +
  134. "Verification Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;" +
  135. "</td>" +
  136. "<td class='vertificationmoveinmulti'>" +
  137. "<input type='text' name='vertifidate_" + count + "'>&nbsp;&nbsp;" +
  138. "&nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;" +
  139. "<input type='checkbox' name='currentdatevert_" + count + "' onClick=vertifidate_" + count + ".value=fill_date()>" +
  140. "</td>" +
  141. "</tr>" +
  142. "</table>";
  143.  
  144. <!--- Adds Extra fields for Dept/Vendor Responsibility  --->
  145. newdiv.innerHTML = newdiv.innerHTML +
  146. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  147. "<tr>" +
  148. "<td class='red' id='paddingformultitop'>" +
  149. "Dept/Vendor Responsibility*:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"  +
  150. "<select name='deptvendor_" + count + "'>" +
  151. "<option value='' selected>Make A Selection</option>" +
  152. "<cfoutput query='getDeptVendor'>" +
  153. "<option value='#pk_deptVendor#'>#pk_deptVendor#</option>" +
  154. " </cfoutput>" +
  155. "</select>" +
  156. "</td>" +
  157. "</tr>" +
  158. "</table>";
  159.  
  160. <!--- Adds Extra fields for RMA Data Only  --->
  161. newdiv.innerHTML = newdiv.innerHTML +
  162. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  163. "<tr>" +
  164. "<td id='paddingformultitop'>" +
  165. "RMA Data Only:&nbsp;&nbsp;&nbsp;&nbsp;" +
  166. "</td>" +
  167. "<td class='rmanmoveinmulti'>" +
  168. "( You may enter up to 1000 characters. )"+
  169. "<br/>" +
  170. "<textarea maxlength='1000' onkeyup='return rmamaxlength(this)' onkeydown='return rmamaxlength(this)' rows='4' cols='60' name='rma_" + count + "'></textarea> " +
  171. "</td>" +
  172. "</tr>" +
  173. "</table>" +
  174. "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
  175. "<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
  176.  
  177. <!--- Adds Delete to every ticket  --->
  178. newdiv.innerHTML = newdiv.innerHTML +
  179. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  180. "<tr>" +
  181. "<td>" +
  182. "<input type='button' class='removeticket' value='Remove Serial &quot;"+ count +"&quot;' onclick=\"removeElement(\'"+divIdName+"\')\"></a>" +
  183. "</td>" +
  184. "</tr>" +
  185. "<tr>" +
  186. "<td>" + 
  187. "<input type='button' class='addticket' value='Add Parts' onclick=\"addpartInput(\'"+divIdName+"\')\">" +
  188. "</td>" +
  189. "</tr>" +
  190. "</table>";
  191.  
  192. document.getElementById(divName).appendChild(newdiv);
  193.  
  194. <!---Allows us to remove multiple fields --->
  195. function removeElement(divNum) {
  196.   var d = document.getElementById('dynamicInput');
  197.   var olddiv = document.getElementById(divNum);
  198.   d.removeChild(olddiv);
  199. }
  200. </script>
  201.  
  202.  
  203.  
  204.  
  205.  
  206. <!---Allows us to add PARTS information multiple times--->
  207. <script type="text/javascript">
  208. <!---Adds multiple fields for parts --->
  209. function addpartInput(partName){
  210. var parts = document.getElementById(partName);
  211. <!---('partsInput')--->
  212.  
  213. <!---this works if only want to add a part under the serial you are working with, but if you have
  214. serial information 1
  215. and serial information 2 an want to add information to serial information 1 you cant because parts always appear under the last serial information added if you click add parts--->
  216. var getparts = document.getElementById('div');
  217. <!---var avalue = document.getElementById('aValue');--->
  218. var serialno = partName.replace("dynamic","").replace("Input","");
  219. var avalue = document.getElementById("partscount"+serialno);
  220. <!---var count = (document.getElementById('avalue').value -1)+ 2;--->
  221. var count = parseInt(avalue.value) + 1;
  222. avalue.value = count;
  223. var partdiv = document.createElement('div');
  224. <!---var partIdName = 'part'+count+'Name';--->
  225. var partIdName = 'part' + count + 'Name' + serialno;
  226. <!---'parts'+count+'Input'--->
  227.  
  228. partdiv.setAttribute('id',partIdName);
  229.  
  230. <!--- Adds Extra fields for parts table  --->
  231. partdiv.innerHTML =
  232. <!---what used originally for this tableclass='createticketables' id='spaceup'--->
  233. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
  234. "<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
  235. "<tr>" +
  236. "<td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;" +
  237. "<input type='text' name='hcpn_" + count + "_"+serialno+"' style='margin:0px'></td>" +
  238. "<td class='red'>" +
  239. "Parts been returned* " +
  240. "<input type='checkbox' name='partsreturn_" + count + "_"+serialno+"' value='1'>" +
  241. "</td>" +
  242. "<td>" +
  243. "<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"_"+serialno+"' value='1'>" +
  244. "</td>" +
  245. "</td>" +
  246. "</tr>" +
  247. "</table>";
  248. <!---"<table table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'  >" +
  249. "<tr>" +
  250. "<td class='indent' id='formfieldpadding'>Follow up Date:(MM/DD/YYYY)&nbsp;&nbsp;&nbsp;"  +
  251. "<input type='text' name='followdate_" + count + "' value='' size='8'/>&nbsp;&nbsp;&nbsp;" +
  252. "Current Date<input type='checkbox' name='followcheck_"+ count +"' value='' onClick='followdate.value=fill_date()'/></td>" +
  253. "<td>On Site:</td>" +
  254. "<td><select name='onsite_" + count +"'>" +
  255. "<option value='No Choice' selected>No Choice</option>" +
  256. "<option value='Yes'>Yes</option>" +
  257. "<option value='No'>No</option>" +
  258. "</select><td>" +
  259. "<td># of Onsite:</td><td><select name='numonsite_" + count +"'>" +
  260. "<option value='' selected>No Choice</option>" +
  261. "<cfloop from='0' to='10' index='nonsite'><cfoutput>" +
  262. "<option value='#nonsite#'>#nonsite#</option></cfoutput></cfloop>" +
  263. "</select><td>" +
  264. "</tr>" +
  265. "</table>";
  266. --->
  267.  
  268. <!--- Adds Delete to every ticket  --->
  269. partdiv.innerHTML = partdiv.innerHTML +
  270. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  271. "<tr>" +
  272. "<td>" +
  273. "<input type='button' class='removeticket' value='Remove Parts &quot;"+count +"&quot;' onclick=\"removetheElement(\'"+partIdName+"\')\"></a>" +
  274. "</td>" +
  275. "</td>" +
  276. "</tr>" +
  277. "</table>";
  278.  
  279. document.getElementById(partName).appendChild(partdiv);
  280.  
  281. <!---Allows us to remove multiple fields--->
  282. function removetheElement(divNum) {
  283.   var d = document.getElementById('partsInput');
  284.   var olddiv = document.getElementById(divNum);
  285.  olddiv.parentNode.removeChild(olddiv);
  286. }
  287.  
  288. </script>
  289.  
  290.  


here is the html/coldfusion that displays what was previously entered for serials and parts.
Expand|Select|Wrap|Line Numbers
  1. <!--- Ticket Information 
  2.        This display the ticket Information--->
  3.  
  4. <!---<input type="hidden" value="0" id="theValue" />--->
  5.     <div id="dynamicInput"> 
  6.      <!--- All Ticket Information Appears Here--->
  7.  
  8.  
  9.     <!--- Shows what was previously entered for Model No, Product Type, and Type of Hardware Failure  --->
  10. <cfset count = 0>
  11. <!---<cfif serial.recordcount is 0>--->
  12. <cfoutput query="serial">
  13. <cfset model_no = #model_no#>
  14. <cfset product_type = #product_type#>
  15. <cfset type_hardware_failure = #type_hardware_failure#>
  16. <cfset software_hardware = #software_hardware#>
  17. <cfset resolution_verified_by = #resolution_verified_by#>
  18. <cfset dept_responsibility = #dept_responsibility#>
  19. <cfset count = count + 1>
  20. <div id="dynamic#count#Input">
  21. <table class="zpExpandedTable" id="modeltable"> 
  22. <th class="sectiontitletick" colspan="7">
  23. Serial Information #count# </th>
  24. <tr>
  25. <td id="paddingformultitop">Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>
  26. </td>
  27. <td>
  28. <select name="modelno_#count#">
  29. <option value="">Make A Selection</option>
  30. <cfloop query="models">
  31. <option value="#model#"<cfif #model# is #model_no#>selected</cfif>>#model#</option>
  32. </cfloop> 
  33. </select>
  34. </td>
  35. <td>
  36. &nbsp;&nbsp;&nbsp;&nbsp;Product Type:
  37. </td>
  38. <td>
  39. <select name="producttype_#count#">
  40. <option value="" selected>No Choice</option>
  41. <cfloop query="getProdType">
  42. <option value="#pk_productType#"<cfif #pk_productType# is #product_type#>selected</cfif>>#pk_productType#</option> 
  43. </cfloop>
  44. </select>
  45. </td>
  46. <td class="red">
  47. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:
  48. </td>
  49. <td>
  50. <select name="hardwarefailure_#count#">
  51. <option value="" selected>Make A Selection</option>
  52. <cfloop query="getHardwareFail">
  53. <option value="#pk_hardwareFailure#"<cfif #pk_hardwareFailure# is #type_hardware_failure#>selected</cfif>>#pk_hardwareFailure#</option>
  54. </cfloop>
  55. </select>
  56. </td>
  57. </tr>
  58. <table>
  59.  
  60. <!--- Shows what was previously entered for Serial Number and Software/Hardware  --->
  61. <table class="zpExpandedTable" id="modeltable">
  62. <tr>
  63. <td id="paddingformultitop">
  64. Serial Number:&nbsp;&nbsp;
  65. <input type="text" name="serialnum_#count#" value="#pka_serialNo#">
  66. &nbsp;&nbsp;&nbsp;&nbsp;Software/Hardware:&nbsp;&nbsp;
  67. <select name="softhardware_#count#">
  68. <option value="" selected>No Choice</option>
  69. <cfloop query="getSoftHard">
  70. <option value="#pk_softwareHardware#"<cfif #pk_softwareHardware# is #software_hardware#>selected</cfif>>#pk_softwareHardware#</option>
  71. </cfloop>
  72. </select>
  73. </td>
  74. </tr>
  75. </table>
  76.  
  77. <!--- Shows what was previously entered for Description ---> 
  78.  
  79. <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
  80. <tr>
  81. <td id="paddingformutli">
  82. Description:&nbsp;&nbsp;
  83. </td>
  84. <td class="descriptionmoveinmulti">
  85. #description#
  86. ( You may enter up to 1000 characters. )
  87. <br>
  88. <textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name="thedescription_#count#"></textarea>
  89. </td>
  90. </tr>
  91. </table>
  92.  
  93. <!---Shows what was previously entered for Resolution  --->
  94.  
  95. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  96. <tr>
  97. <td id="paddingformutli">
  98. Resolution:&nbsp;&nbsp;
  99. </td>
  100. <td class="resolutionmoveinmulti">
  101. ( You may enter up to 1500 characters. )
  102. <br>
  103. <textarea  maxlength="1500" onkeyup="return resolutionismaxlength(this)" onkeydown="return resolutionismaxlength(this)" rows="4" cols="60" name="resolution_#count#">#resolution#</textarea>
  104. </td>
  105. </tr>
  106. </table>
  107.  
  108. <!--- Shows what was previously entered for Resolution Date, Current Date (for resolution date) and resolution vertified as effective by  --->
  109.  
  110. <table class="zpExpandedTable" id="resoldatetab" cellpadding="1" cellspacing="0">
  111. <tr>
  112. <td id="paddingformultitop">
  113. Resolution Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
  114. </td>
  115. <td>
  116. <input type="text" name="resdate_#count#" value="#DateFormat(resolution_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
  117. &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
  118. <input type="checkbox" name="currentdateresol_#count#" 
  119. onClick="resdate_#count#.value=fill_date()">
  120. </td>
  121. <td>
  122. Resolution Verified as effective by:&nbsp;&nbsp;
  123. </td>
  124. <td>
  125. <select name="resvertified_#count#">
  126. <option value="" selected>Make A Selection</option>
  127. <cfloop query="gettech">
  128. <option value="#fname# #lname#"<cfif "#fname# #lname#" is #resolution_verified_by#>
  129. selected</cfif>>#fname# #lname#</option>
  130. </cfloop>
  131. </select>
  132. </td>
  133. </tr>
  134. </table>
  135. <!--- Shows what was previously entered for Vertification Date, Current Date (for vertification date)   --->
  136. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  137. <tr>
  138. <td id="paddingformultitop">
  139. Verification Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
  140. </td>
  141. <td class="vertificationmoveinmulti">
  142. <input type="text" name="vertifidate_#count#" value="#DateFormat(verification_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
  143. &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
  144. <input type="checkbox" name="currentdatevert_#count#" 
  145. onClick="vertifidate_#count#.value=fill_date()">
  146. </td>
  147. </tr>
  148. </table>
  149.  
  150. <!--- Shows what was previously entered for Dept/Vendor Responsibility  --->
  151. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  152. <tr>
  153. <td class="red" id="paddingformultitop">
  154. Dept/Vendor Responsibility*:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  155. <select name="deptvendor_#count#">
  156. <option value="" selected>Make A Selection</option>
  157. <cfloop query="getDeptVendor">
  158. <option value="#pk_deptVendor#"<cfif #pk_deptVendor# is #dept_responsibility#>selected</cfif>>#pk_deptVendor#</option>
  159. </cfloop>
  160. </select>
  161. </td>
  162. </tr>
  163. </table>
  164.  
  165. <!--- Shows what was previously entered for RMA Data Only  --->
  166. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  167. <tr>
  168. <td id="paddingformultitop">
  169. RMA Data Only:&nbsp;&nbsp;&nbsp;&nbsp;
  170. </td>
  171. <td class="rmanmoveinmulti">
  172. ( You may enter up to 1000 characters. )
  173. <br/>
  174. <textarea maxlength="1000" onkeyup="return rmaismaxlength(this)" onkeydown="return rmaismaxlength(this)" rows="4" cols="60" name="rma_#count#" >#rma_data#</textarea>
  175. </td>
  176. </tr>
  177. </table>
  178. <input type="hidden" name="serialcount" value="#count#">
  179.  
  180. <!--- Adds Delete to every ticket  --->
  181. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  182. <tr>
  183. <td>
  184. <input type="button" class="removeticket" value="Remove Serial #count#" onclick="removeElement('dynamic#count#Input')">
  185. </td>
  186. </tr>
  187. <tr>
  188. <td>
  189. <!---<input type='button' class='addticket' value='Add Parts' onclick="addpartInput('divIdName')">--->
  190. </td>
  191. </tr>
  192. </table>
  193.  
  194. <cfset count1 = 0>
  195. <!---<cfif serial.recordcount is 0>--->
  196. <cfloop query="parts">
  197. <cfset count1 = count1 + 1>
  198. <!---THIS IS THE PARTS SECTION--->
  199. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  200. <th class="sectiontitle" colspan="7">Parts Information #count1# Serial Information #count#</th>
  201. <tr>
  202. <td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;<input type='text' name="hcpn_#count1#" style="margin:0px" value="#hc_partNo#"></td>
  203. <td class="red">
  204. Parts been returned*
  205. <input type="checkbox" name="partsreturn_#count1#" value="#part_returned#"<cfif #part_returned# eq "1">checked=yes</cfif>/>
  206. </td>
  207. <td>
  208. <td class="indent">Defective<input type="checkbox" name="defective_#count#1" value="#defective#"<cfif #defective# eq "1">checked=yes</cfif>/></td>
  209. </td>
  210. </tr>
  211. </table>
  212.  
  213. <!--- Adds Delete to every ticket  --->
  214. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  215. <tr>
  216. <td>
  217. <input type="button" class="removeticket" value="Remove Parts #count1#" 
  218. onclick="removetheElement('partIdName')"></a>
  219. </td>
  220. </td>
  221. </tr>
  222. </table>
  223. </cfloop>
  224. </div>
  225. </cfoutput>
  226. <input type="hidden" value="<cfoutput>#count#</cfoutput>" name="theValue" id="theValue" />
  227.  
  228.  
  229. <!---If have any blanks in serial table it will make field appear--->
  230. <cfoutput query="serial">
  231. <cfset model_no = #model_no#>
  232. <cfset product_type = #product_type#>
  233. <cfset type_hardware_failure = #type_hardware_failure#>
  234. <cfset pka_serialNo = #pka_serialNo#>
  235. <cfset software_hardware = #software_hardware#>
  236. <cfset description = #description#>
  237. <cfset resolution = #resolution#>
  238. <cfset resolution_date = #resolution_date#>
  239. <cfset resolution_verified_by = #resolution_verified_by#>
  240. <cfset verification_date = #verification_date#>
  241. <cfset dept_responsibility = #dept_responsibility#>
  242. <cfset rma_data = #rma_data#>
  243. </cfoutput>
  244. <cfif serial.recordcount is 0>
  245. <cfset model_no = "">
  246. <cfset product_type = "">
  247. <cfset type_hardware_failure = "">
  248. <cfset pka_serialNo = "">
  249. <cfset software_hardware = "">
  250. <cfset description = "">
  251. <cfset resolution = "">
  252. <cfset resolution_date = "">
  253. <cfset resolution_verified_by = "">
  254. <cfset verification_date = "">
  255. <cfset dept_responsibility = "">
  256. <cfset rma_data = "">
  257. <cfinclude template="serialdisplay.cfm">
  258. </cfif>
  259. <!---
  260. <cfset count = 0>
  261. <cfoutput query="parts">
  262. <cfset count = count + 1>
  263. <div id="partscount#count#">
  264.  
  265. <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
  266. <tr>
  267. <td class="indent" id="formfieldpadding">Follow up Date:(MM/DD/YYYY)&nbsp;&nbsp;&nbsp;
  268. <input type="text" name="followdate_#count#" value="" size="8"/>&nbsp;&nbsp;&nbsp;
  269. Current Date<input type="checkbox" name="followcheck_#count#" value="" onClick="followdate.value=fill_date()"/></td>
  270. <td>On Site:</td>
  271. <td><select name="onsite_#count#">
  272. <option value="No Choice" selected>No Choice</option>
  273. <option value="Yes">Yes</option>
  274. <option value="No">No</option>
  275. </select><td>
  276. <td># of Onsite:</td><td><select name="numonsite_#count#">
  277. <option value="" selected>No Choice</option>
  278. <cfloop from="0" to="10" index="nonsite"><cfoutput>
  279. <option value="#nonsite#">#nonsite#</option></cfoutput></cfloop>
  280. </select><td>
  281. </tr>
  282. </table>
  283. <input type="hidden" name="serialcount" value="#count#">
  284.  
  285.  
  286.  
  287.  
  288. <!--- Parts Information, display parts if have or don't have a value --->
  289. <cfoutput query="parts">
  290. <cfset hc_partNo = #hc_partNo#>
  291. <cfset part_returned = #part_returned#>
  292. <cfset defective = #defective#>
  293. <cfinclude template="partsdisplay.cfm">
  294. </cfoutput>
  295. <cfif parts.recordcount is 0>
  296. <cfset hc_partNo = "">
  297. <cfset part_returned = "">
  298. <cfset defective = "">
  299. <cfoutput><cfinclude template="partsdisplay.cfm"></cfoutput>
  300. </cfif>
  301.  
  302. ---></div>
  303.      <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
  304.  
  305.  
Thank you in advance,
Rach
Oct 16 '08
482 24510
bonneylake
769 512MB
Does this problem occur when no parts have been added at all or when you add a part and then delete it (leaving no parts)?
Hey Acoder,

It still occurs when i don't add a part. An it happens when i add a part an then delete it.

Thank you,
Rach
Oct 21 '08 #51
acoder
16,027 Expert Mod 8TB
<cfloop> has a number of different types. The one you're using here is an index loop. You can also use a conditional loop which might make sense here. You check the condition before entering the loop. See documentation.
Oct 22 '08 #52
bonneylake
769 512MB
<cfloop> has a number of different types. The one you're using here is an index loop. You can also use a conditional loop which might make sense here. You check the condition before entering the loop. See documentation.
Hey Acoder,

well the only thing i am worried about the conditional loop is i don't know how many parts they will add or if they will add a part. So would it still work if i had a part or if i didn't have a part? an then if it would work would what i set cfset to. In the example they use <cfset CountVar = 0> do i need to set mine to something like

Expand|Select|Wrap|Line Numbers
  1. <cfset ps = "#form['partscount' & machinecount]#">
Thank you,
Rach
Oct 22 '08 #53
acoder
16,027 Expert Mod 8TB
You could set ps to 1 then in the cfloop condition, check that it's less than the count. If the count is 0, the code in the loop wouldn't execute.

There's one other approach which may make sense here. It ties in with the second method for deleting parts where you have a list of part numbers. Here you would loop over the list. If the list is empty, it doesn't try to insert parts.
Oct 22 '08 #54
bonneylake
769 512MB
You could set ps to 1 then in the cfloop condition, check that it's less than the count. If the count is 0, the code in the loop wouldn't execute.

There's one other approach which may make sense here. It ties in with the second method for deleting parts where you have a list of part numbers. Here you would loop over the list. If the list is empty, it doesn't try to insert parts.
Hey Acoder,

Well whatever direction you think would be best then all go with that.So if i was to go with the second idea you have how would i go about that.

Thank you,
Rach
Oct 22 '08 #55
acoder
16,027 Expert Mod 8TB
Keep a hidden field to list the part numbers separated by commas, i.e. a Coldfusion list, e.g. "1,3,4,5,". This could either be in addition to the count or replace it. In the add parts function, you would add the part number to the field with a comma. In the delete parts function, remove the number from the field. On the Coldfusion side, loop over this list.
Oct 22 '08 #56
bonneylake
769 512MB
Keep a hidden field to list the part numbers separated by commas, i.e. a Coldfusion list, e.g. "1,3,4,5,". This could either be in addition to the count or replace it. In the add parts function, you would add the part number to the field with a comma. In the delete parts function, remove the number from the field. On the Coldfusion side, loop over this list.

Hey Acoder,

ok i am mostly confused by the first part. Am i suppose to be creating a hidden field or a coldfusion list like below

Expand|Select|Wrap|Line Numbers
  1. <cfset coldfusion_list = "ColdFusion Lists,ColdFusion Arrays,ColdFusion Structures">
  2.  
  3. <cfloop list="#coldfusion_list#" index="i">
  4.    <cfoutput> #i# <br />
  5.   </cfloop>
an then where would this hidden field or coldfusion list go? would it go under the serial or parts function?

Thank you,
Rach
Oct 22 '08 #57
acoder
16,027 Expert Mod 8TB
By hidden field, I meant an input field on the client side, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="parts1list1" id="parts1list1" value="">
This would be set using JavaScript to "1," initially when the first part is added. As more are added/deleted, this list can become something like "1,2,4,5,"
Oct 22 '08 #58
bonneylake
769 512MB
By hidden field, I meant an input field on the client side, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="parts1list1" id="parts1list1" value="">
This would be set using JavaScript to "1," initially when the first part is added. As more are added/deleted, this list can become something like "1,2,4,5,"
Hey Acoder,

So does it go to the place below or do i need to add it somewhere in the parts function?

Expand|Select|Wrap|Line Numbers
  1. <!--- Ticket Information --->
  2. <input type="hidden" value="0" id="theValue" name="theValue"/>
  3. <input type="hidden" name="parts1list1" id="parts1list1" value="">
  4. <!---<input type="hidden" value="0" id="aValue" />
  5. --->     <div id="dynamicInput">
  6. <!---      All Ticket Information and Parts information Appears Here--->
  7.      </div>
  8.      <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
Thank you,
Rach
Oct 22 '08 #59
acoder
16,027 Expert Mod 8TB
It should go next to the partscount input field in the addInput() function.
Oct 22 '08 #60
bonneylake
769 512MB
It should go next to the partscount input field in the addInput() function.
Hey Acoder,

So something like this correct?

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
  2. "<input type="hidden" name="parts1list1" id="parts1list1" value="">" +
  3. "<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
  4.  
  5. <!--- Adds Delete to every ticket  --->
  6. newdiv.innerHTML = newdiv.innerHTML +
Thank you,
Rach
Oct 22 '08 #61
acoder
16,027 Expert Mod 8TB
Of course, "parts1list1" was only an example. It needs to be a variable constructed similar to partc.
Oct 22 '08 #62
bonneylake
769 512MB
Of course, "parts1list1" was only an example. It needs to be a variable constructed similar to partc.
Hey Acoder,

Ok so i added this in the function addinput

Expand|Select|Wrap|Line Numbers
  1. var partc = 'partscount'+count;
  2. var part2c = 'part2count'+count;
an then here is the 2 hidden fields
Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
  2. "<input type="hidden" name='"+part2c+"' id='"+part2c+"' value="">" +
Is this correct?

Thank you,
Rach
Oct 22 '08 #63
acoder
16,027 Expert Mod 8TB
That's one thing done. Then in addInput, you need to update this field with the count number plus a comma. In the delete function, remove the part number being deleted.
Oct 22 '08 #64
bonneylake
769 512MB
That's one thing done. Then in addInput, you need to update this field with the count number plus a comma. In the delete function, remove the part number being deleted.
Hey Acoder,

How would i go about updateing it? something like

Expand|Select|Wrap|Line Numbers
  1. part update = 'part2count'+count';
an then for delete, would i delete it like so from the addinput function?

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.part2c(olddiv);
  6. }
Thank you,
Rach
Oct 22 '08 #65
acoder
16,027 Expert Mod 8TB
Although this is now JavaScript, since it links with the Coldfusion, we can leave it in this thread.

For the adding, look how you update the parts count. Do something similar with this new field with the difference being that instead of setting the count value, you append it using +=
Oct 22 '08 #66
bonneylake
769 512MB
Although this is now JavaScript, since it links with the Coldfusion, we can leave it in this thread.

For the adding, look how you update the parts count. Do something similar with this new field with the difference being that instead of setting the count value, you append it using +=
Hey Acoder,

Confused by, are you meaning something like

Expand|Select|Wrap|Line Numbers
  1. var partupdate = 'part2count'+=count';
or maybe

Expand|Select|Wrap|Line Numbers
  1. var partupdate = 'part2count'+count+=';
Thank you,
Rach
Oct 22 '08 #67
acoder
16,027 Expert Mod 8TB
Sorry, I meant in addpartInput(), you have something like:
Expand|Select|Wrap|Line Numbers
  1. var serialno = partName.replace("dynamic","").replace("Input","");
  2. var avalue = document.getElementById("partscount"+serialno);
  3. var count = parseInt(avalue.value) + 1;
  4. avalue.value = count;
so you'd use something similar for parts2count except that instead of avalue.value = count, you'd set partslist.value += count + ",".
Oct 22 '08 #68
bonneylake
769 512MB
Sorry, I meant in addpartInput(), you have something like:
Expand|Select|Wrap|Line Numbers
  1. var serialno = partName.replace("dynamic","").replace("Input","");
  2. var avalue = document.getElementById("partscount"+serialno);
  3. var count = parseInt(avalue.value) + 1;
  4. avalue.value = count;
so you'd use something similar for parts2count except that instead of avalue.value = count, you'd set partslist.value += count + ",".
Hey Acoder,

I added this to addpartInput. does it need to be partslist or does it need to part2c?

Expand|Select|Wrap|Line Numbers
  1. var count = parseInt(avalue.value) + 1;
  2. avalue.value = count;
  3. partslist.value += count + ",";
Thank you,
Rach
Oct 22 '08 #69
acoder
16,027 Expert Mod 8TB
partslist was just a variable name that I made up. You'll need to set it to the element in question first before setting its value:
Expand|Select|Wrap|Line Numbers
  1. var partslist = document.getElementById("parts2count"+serialno);
Oct 23 '08 #70
bonneylake
769 512MB
partslist was just a variable name that I made up. You'll need to set it to the element in question first before setting its value:
Expand|Select|Wrap|Line Numbers
  1. var partslist = document.getElementById("parts2count"+serialno);
Hey Acoder,

So something like this correct?

Expand|Select|Wrap|Line Numbers
  1. avalue.value = count;
  2. var partslist = document.getElementById("parts2count"+serialno);
  3. partslist.value += count + ",";
Thank you,
Rach
Oct 23 '08 #71
acoder
16,027 Expert Mod 8TB
That's one part done. Now you need to add some lines in the delete function to remove the part number being deleted. You'll need the serial number again, so you can copy that line. The input field value is a string, so you can use replace() like how you set the serialno variable.
Oct 23 '08 #72
bonneylake
769 512MB
That's one part done. Now you need to add some lines in the delete function to remove the part number being deleted. You'll need the serial number again, so you can copy that line. The input field value is a string, so you can use replace() like how you set the serialno variable.
Hey Acoder,

Not sure if i copied the 2 correct lines, but here is what i have. I added it to the delete function in the parts function

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields--->
  2. function removetheElement(divNum) {
  3.   var d = document.getElementById('partsInput');
  4.   var partslist = document.getElementById("parts2count"+serialno);
  5.   var serialno = partName.replace("dynamic","").replace("Input","");
  6.   var olddiv = document.getElementById(divNum);
  7.  olddiv.parentNode.removeChild(olddiv);
  8. }
Thank you,
Rach
Oct 23 '08 #73
acoder
16,027 Expert Mod 8TB
divNum which is passed into this function is partIdName set in the addpartInput function. partIdName is set like this:
Expand|Select|Wrap|Line Numbers
  1. var partIdName = 'part' + count + 'Name' + serialno;
so you need to do some string manipulation (see methods) to get the count and serial number values.
Oct 23 '08 #74
bonneylake
769 512MB
divNum which is passed into this function is partIdName set in the addpartInput function. partIdName is set like this:
Expand|Select|Wrap|Line Numbers
  1. var partIdName = 'part' + count + 'Name' + serialno;
so you need to do some string manipulation (see methods) to get the count and serial number values.
Hey Acoder,

Ok are you saying the 2 strings i added where incorrect an i need to add the line you have above? an then what type of string manipulation do i need to do to it? something like

Expand|Select|Wrap|Line Numbers
  1. var replace = partIDName.replace("part","count").replace("Name","serialno");
  2.  
Thank you,
Rach
Oct 23 '08 #75
acoder
16,027 Expert Mod 8TB
No. That line was where you set the div ID in addpartInput(). Notice the ID contains both the part number (count) that needs to be removed and the serial no. So it could be something like "part2Name2". To get the part number, you need to remove "part" from it and then you can split on "Name" to get an array [2,2].
Oct 23 '08 #76
bonneylake
769 512MB
No. That line was where you set the div ID in addpartInput(). Notice the ID contains both the part number (count) that needs to be removed and the serial no. So it could be something like "part2Name2". To get the part number, you need to remove "part" from it and then you can split on "Name" to get an array [2,2].
Hey Acoder,

Do i need to keep the 2 lines i added above in the remove? an i am confused on the split completely, here is what i tried but i got a feeling this is not right

Expand|Select|Wrap|Line Numbers
  1. var replace = partIDName.split("Name","serialno");
Thank you,
Rach
Oct 23 '08 #77
acoder
16,027 Expert Mod 8TB
You'd need the partslist line, but not the serialno line which will be set from the divNum. Forget partIDName. That's what the variable was called when set in addpartinput. In the delete function, it's called divNum.
Oct 23 '08 #78
bonneylake
769 512MB
You'd need the partslist line, but not the serialno line which will be set from the divNum. Forget partIDName. That's what the variable was called when set in addpartinput. In the delete function, it's called divNum.
Hey Acoder,

Ok so something like this?

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields--->
  2. function removetheElement(divNum) {
  3.   var d = document.getElementById('partsInput');
  4.   var partslist = document.getElementById("parts2count"+serialno);
  5.   var replace = divnum.split("Name","serialno");
  6.   var olddiv = document.getElementById(divNum);
  7.  olddiv.parentNode.removeChild(olddiv);
  8. }
an i got another question i wanted to ask you about. Right now i am working on the edit part of the form. An well i can not update previously submitted serial's an wanted to ask can cfqueryparam prevent you from updating your table? i copied the one i used to insert and just changed the exec from insert to update. But cant seem to get it. Keeps giving me the error Procedure or function usp_CS_UpdateInsertserial has too many arguments specified an i been trying to figure this out for days. Could you give me an idea of what it could be? i been looking online an said its to many parameters but i have checked it a million times an its right. The only thing i can think of is my update insert stored procedure is messed up.

Thank you,
Rach
Oct 23 '08 #79
acoder
16,027 Expert Mod 8TB
Try running that code and see what happens. It won't work. serialno won't be defined. You need to define it first before you can use it. Also, see the link I gave earlier to see how to use split(). You also need to remove "part" first by using replace().

As for the new question, start a new thread. There's enough sub-questions in this thread without adding yet another one ;)
Oct 23 '08 #80
acoder
16,027 Expert Mod 8TB
Try running that code and see what happens. It won't work. serialno won't be defined. You need to define it first before you can use it. Also, see the link I gave earlier to see how to use split(). You also need to remove "part" first by using replace().
Actually scrap that. I ain't got my thinking cap on!

Just pass the serial number and count in removetheElement() to make things a lot easier:
Expand|Select|Wrap|Line Numbers
  1. onclick=\"removetheElement('"+partIdName+"',"+serialno+","+count+")\"
Oct 23 '08 #81
bonneylake
769 512MB
Actually scrap that. I ain't got my thinking cap on!

Just pass the serial number and count in removetheElement() to make things a lot easier:
Expand|Select|Wrap|Line Numbers
  1. onclick=\"removetheElement('"+partIdName+"',"+serialno+","+count+")\"
Hey Acoder,

Here is the remove for the parts section. Is there anything else it needs?

Expand|Select|Wrap|Line Numbers
  1. "<input type='button' class='removeticket' value='Remove Parts &quot;"+count +"&quot;' onclick=\"removetheElement('"+partIdName+"',"+serialno+","+count+")\"></a>" +
an also do i need to remove those 2 lines from the removetheelement function

Expand|Select|Wrap|Line Numbers
  1.   var partslist = document.getElementById("parts2count"+serialno);
  2.   var replace = divnum.split("Name","serialno");
an do i need to post my question in coldfusion or sql server? an i think i might have my own question for this sql problem figured out. It thinks that my pk_ticketID (which holds the ticket number) is the
serial number. If i take out pk_ticketID it says that pka_serialNo can not be null and the insert fails. In the cfset could i add or do i need to add pk_ticketID?

Thank you,
Rach
Oct 23 '08 #82
acoder
16,027 Expert Mod 8TB
You'll need to add two parameters to the removetheElement function:
Expand|Select|Wrap|Line Numbers
  1. function removetheElement(divNum, serialno, partnum) {
Of those two lines, you don't need the replace line. You need to set partslist.value to itself, but replaced with partnum+',' missing.

Re. your SQL question. If you think it's a pure SQL question, post it in SQL Server, and if not, Coldfusion it is.
Oct 23 '08 #83
bonneylake
769 512MB
You'll need to add two parameters to the removetheElement function:
Expand|Select|Wrap|Line Numbers
  1. function removetheElement(divNum, serialno, partnum) {
Of those two lines, you don't need the replace line. You need to set partslist.value to itself, but replaced with partnum+',' missing.

Re. your SQL question. If you think it's a pure SQL question, post it in SQL Server, and if not, Coldfusion it is.
Hey Acoder,

Would this be correct?

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields--->
  2. function removetheElement(divNum, serialno, partnum) {
  3.   var d = document.getElementById('partsInput');
  4.   var partslist = document.getElementById("parts2count"+serialno);
  5.   partslist.value += partnum + ',';
  6.   var olddiv = document.getElementById(divNum);
  7.  olddiv.parentNode.removeChild(olddiv);
  8. }
Thank you,
Rach
Oct 23 '08 #84
acoder
16,027 Expert Mod 8TB
Line 5 is not quite correct. You want to remove partnum from partslist, so use replace() to replace with "" to remove it.
Oct 23 '08 #85
bonneylake
769 512MB
[quote=acoder]Line 5 is not quite correct. You want to remove partnum from partslist, so use replace() to replace with "" to remove it.[/QUOTE

Hey Acoder,

are you meaning something like this?

Expand|Select|Wrap|Line Numbers
  1. partslist.value += replace(partnum) + ',';
Thank you,
Rach
Oct 23 '08 #86
acoder
16,027 Expert Mod 8TB
No, replace is a String method, so it'd be applied to partslist.value. See how you've used it before. Something like: partslist.value.replace(partnum+',',"")
Oct 23 '08 #87
bonneylake
769 512MB
No, replace is a String method, so it'd be applied to partslist.value. See how you've used it before. Something like: partslist.value.replace(partnum+',',"")
Hey Acoder,

so would this be right?
Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields--->
  2. function removetheElement(divNum, serialno, partnum) {
  3.   var d = document.getElementById('partsInput');
  4.   var partslist = document.getElementById("parts2count"+serialno);
  5.   partslist.value.replace(partnum+',',"");
  6.   var olddiv = document.getElementById(divNum);
  7.  olddiv.parentNode.removeChild(olddiv);
  8. }
Thank you,
Rach
Oct 23 '08 #88
acoder
16,027 Expert Mod 8TB
What line 5 would do is remove the part number (which is what you want), but then it'd be lost because it's not set to anything. So you need to set the result of that to partslist.value.

PS. not sure what line 3 is doing there. It must have been left over from some old code.
Oct 24 '08 #89
bonneylake
769 512MB
What line 5 would do is remove the part number (which is what you want), but then it'd be lost because it's not set to anything. So you need to set the result of that to partslist.value.

PS. not sure what line 3 is doing there. It must have been left over from some old code.
Hey Acoder,

Well line 3 has always been there but do i need to remove it? an i am confused by what you mean about seeing the results of that to partlist.value. are you saying need to add it to the last line of code where it says olddiv.parentNode.removeChild(olddiv);?

Thank you,
Rach
Oct 24 '08 #90
acoder
16,027 Expert Mod 8TB
You can safely remove it because it's never used.

To set partslist.value:
Expand|Select|Wrap|Line Numbers
  1. partslist.value = partslist.value.replace...
Oct 24 '08 #91
bonneylake
769 512MB
You can safely remove it because it's never used.

To set partslist.value:
Expand|Select|Wrap|Line Numbers
  1. partslist.value = partslist.value.replace...
Hey Acoder,

Is this correct? does it need anything else?
Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields--->
  2. function removetheElement(divNum, serialno, partnum) {
  3.   var partslist = document.getElementById("parts2count"+serialno);
  4.   partslist.value = partslist.value.replace(partnum+',',"");
  5.   var olddiv = document.getElementById(divNum);
  6.  olddiv.parentNode.removeChild(olddiv);
  7. }
Thank you,
Rach
Oct 24 '08 #92
acoder
16,027 Expert Mod 8TB
I don't think so. Test it now to see if it's all working on the client side.
Oct 24 '08 #93
bonneylake
769 512MB
I don't think so. Test it now to see if it's all working on the client side.
Hey Acoder,

Well it still don't work. Right now it wont display parts it says partslist has no properties and its refering to

Expand|Select|Wrap|Line Numbers
  1. var count = parseInt(avalue.value) + 1;
  2. avalue.value = count;
  3. var partslist = document.getElementById("parts2count"+serialno);
here is what i have in full the funcion for the serial

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!---Allows us to add multiple fields --->
  3. function addInput(divName){
  4. var dynamic = document.getElementById('dynamicInput');
  5. var thevalue = document.getElementById('theValue');
  6. var count = (document.getElementById('theValue').value -1)+ 2;
  7. thevalue.value = count;
  8. var newdiv = document.createElement('div');
  9. var getparts = document.createElement('div');
  10. var divIdName = 'dynamic'+count+'Input';
  11. var partc = 'partscount'+count;
  12. var part2c = 'part2count'+count;
  13.  
  14. "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
  15. "<input type='hidden' name='"+part2c+"' id='"+part2c+"' value=''>" +
  16. "<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
for the parts function

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!---Adds multiple fields for parts --->
  3. function addpartInput(partName){
  4. var parts = document.getElementById(partName);
  5. var getparts = document.getElementById('div');
  6. var serialno = partName.replace("dynamic","").replace("Input","");
  7. var avalue = document.getElementById("partscount"+serialno);
  8. var count = parseInt(avalue.value) + 1;
  9. avalue.value = count;
  10. var partslist = document.getElementById("parts2count"+serialno);
  11. partslist.value += count + ",";
  12. var partdiv = document.createElement('div');
  13. var partIdName = 'part' + count + 'Name' + serialno;
and remove for parts section

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to remove multiple fields--->
  2. function removetheElement(divNum, serialno, partnum) {
  3.   var partslist = document.getElementById("parts2count"+serialno);
  4.   partslist.value = partslist.value.replace(partnum+',',"");
  5.   var olddiv = document.getElementById(divNum);
  6.  olddiv.parentNode.removeChild(olddiv);
  7. }
Thank you,
Rach
Oct 24 '08 #94
acoder
16,027 Expert Mod 8TB
You've named/ID'ed it as "part2count...", not "parts2count...". Be consistent either way.
Oct 24 '08 #95
bonneylake
769 512MB
You've named/ID'ed it as "part2count...", not "parts2count...". Be consistent either way.
Hey Acoder,

Alrighty i fixed it, It lets me add and remove parts again. But it still when i submit it with no parts showing (meaning only selected the serial an no parts added to it) i get the error

An error occurred while evaluating the expression:

hcpn = Form["hcpn_" & ps & "_#machinecount#"]

Error near line 95, column 8.

The member "HCPN_1_1" in dimension 1 of object "Form" cannot be found. Please, modify the member name.

it basically says its having trouble with cfset hcpn on my userform.cfm. which here is the userform.

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  2. <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
  3. <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
  4.  <CFSET hcpn            = Form["hcpn_" & ps & "_#machinecount#"]>
  5.  <CFSET partsreturn     = Form["partsreturn_" & ps & "_#machinecount#"]>
  6.  <CFSET defective       = Form["defective_" & ps & "_#machinecount#"]>
  7.  <CFSET rma             = Form["rma_" & ps & "_#machineCount#"]>
  8. <cfquery name="parts" datasource="CustomerSupport">
  9.     exec usp_CS_Insertparts
  10.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     '#Form.ID#',
  12.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  13.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  14.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  15.     <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  16. </cfquery>
  17. </cfloop>
Thank you,
Rach
Oct 24 '08 #96
acoder
16,027 Expert Mod 8TB
You need to change the cfloop to loop over the part2count+machinecount list instead of 1 to a specific number.
Oct 24 '08 #97
bonneylake
769 512MB
You need to change the cfloop to loop over the part2count+machinecount list instead of 1 to a specific number.
Hey Acoder,

am i suppose to do it this way?

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['part2count' & machinecount]#" index="ps">
  2. <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
  3. <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
  4.  <CFSET hcpn            = Form["hcpn_" & ps & "_#machinecount#"]>
  5.  <CFSET partsreturn     = Form["partsreturn_" & ps & "_#machinecount#"]>
  6.  <CFSET defective       = Form["defective_" & ps & "_#machinecount#"]>
  7.  <CFSET rma             = Form["rma_" & ps & "_#machineCount#"]>
  8. <cfquery name="parts" datasource="CustomerSupport">
  9.     exec usp_CS_Insertparts
  10.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     '#Form.ID#',
  12.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  13.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  14.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  15.     <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  16. </cfquery>
  17. </cfloop>
or this way

Expand|Select|Wrap|Line Numbers
  1. <cfloop from=#form.part2count#" to="#form['partscount' & machinecount]#" index="ps">
  2. <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
  3. <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
  4.  <CFSET hcpn            = Form["hcpn_" & ps & "_#machinecount#"]>
  5.  <CFSET partsreturn     = Form["partsreturn_" & ps & "_#machinecount#"]>
  6.  <CFSET defective       = Form["defective_" & ps & "_#machinecount#"]>
  7.  <CFSET rma             = Form["rma_" & ps & "_#machineCount#"]>
  8. <cfquery name="parts" datasource="CustomerSupport">
  9.     exec usp_CS_Insertparts
  10.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     '#Form.ID#',
  12.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  13.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  14.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  15.     <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  16. </cfquery>
  17. </cfloop>
Thank you,
Rach
Oct 24 '08 #98
acoder
16,027 Expert Mod 8TB
Neither ;) You need to use the list attribute because you're looping over a list.
Oct 24 '08 #99
bonneylake
769 512MB
Neither ;) You need to use the list attribute because you're looping over a list.
Hey Acoder,

Would something like this work?
Expand|Select|Wrap|Line Numbers
  1. <cfloop list="#form['part2count' & machinecount]#" default="ps">
  2. <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
  3. <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
  4.  <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
  5.  <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
  6.  <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
  7.  <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
  8. <cfquery name="parts" datasource="CustomerSupport">
  9.     exec usp_CS_Insertparts
  10.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     '#Form.ID#',
  12.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  13.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  14.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  15.     <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  16. </cfquery>
  17. </cfloop>
Thank you,
Rach
Oct 24 '08 #100

Post your reply

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

Similar topics

4 posts views Thread by Vigneshwar Pilli via DotNetMonster.com | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.