By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Insert Multiple Parts Problem

100+
P: 769
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 the parts section an i seem to be having trouble.

When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections below work except the.Inserts parts information into parts table section.

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.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  56.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  57.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
  58. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  59. </cfquery>
  60.  
  61. </CFLOOP>
  62. </CFIF>
  63.  

here is the multiple fields section in my form for the serial section.

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' value='0' id='"+partc+"' \>" +
  175. "<input type='hidden' name='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>
here is the multiple field section for the parts section

Expand|Select|Wrap|Line Numbers
  1. <!---Allows us to add PARTS information multiple times--->
  2. <script type="text/javascript">
  3. <!---Adds multiple fields for parts --->
  4. function addpartInput(partName){
  5. var parts = document.getElementById(partName);
  6. var getparts = document.getElementById('div');
  7. var serialno = partName.replace("dynamic","").replace("Input","");
  8. var avalue = document.getElementById("partscount"+serialno);
  9. var count = parseInt(avalue.value) + 1;
  10. avalue.value = count;
  11. var partdiv = document.createElement('div');
  12. var partIdName = 'part' + count + 'Name' + serialno;
  13.  
  14. partdiv.setAttribute('id',partIdName);
  15.  
  16. <!--- Adds Extra fields for parts table  --->
  17. partdiv.innerHTML =
  18. <!---what used originally for this tableclass='createticketables' id='spaceup'--->
  19. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
  20. "<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
  21. "<tr>" +
  22. "<td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;<input type='text' name='hcpn_" + count + "' style='margin:0px'></td>" +
  23. "<td class='red'>" +
  24. "Parts been returned* " +
  25. "<input type='checkbox' name='partsreturn_" + count +"' value='1'/>" +
  26. "</td>" +
  27. "<td>" +
  28. "<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"' value='1'/></td>" +
  29. "</td>" +
  30. "</tr>" +
  31. "</table>" +
  32. "<table table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'  >" +
  33. "<tr>" +
  34. "<td class='indent' id='formfieldpadding'>Follow up Date:(MM/DD/YYYY)&nbsp;&nbsp;&nbsp;"  +
  35. "<input type='text' name='followdate_" + count + "' value='' size='8'/>&nbsp;&nbsp;&nbsp;" +
  36. "Current Date<input type='checkbox' name='followcheck_"+ count +"' value='' onClick='followdate.value=fill_date()'/></td>" +
  37. "<td>On Site:</td>" +
  38. "<td><select name='onsite_" + count +"'>" +
  39. "<option value='No Choice' selected>No Choice</option>" +
  40. "<option value='Yes'>Yes</option>" +
  41. "<option value='No'>No</option>" +
  42. "</select><td>" +
  43. "<td># of Onsite:</td><td><select name='numonsite_" + count +"'>" +
  44. "<option value='' selected>No Choice</option>" +
  45. "<cfloop from='0' to='10' index='nonsite'><cfoutput>" +
  46. "<option value='#nonsite#'>#nonsite#</option></cfoutput></cfloop>" +
  47. "</select><td>" +
  48. "</tr>" +
  49. "</table>" +
  50. <!---"<input type='hidden' value='0' id='aValue' />" +--->
  51. "<input type='hidden' name='serialcount' value='" + count + "'>";
  52.  
  53.  
  54. <!--- Adds Delete to every ticket  --->
  55. partdiv.innerHTML = partdiv.innerHTML +
  56. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0'>" +
  57. "<tr>" +
  58. "<td>" +
  59. "<input type='button' class='removeticket' value='Remove Parts &quot;"+count +"&quot;' onclick=\"removetheElement(\'"+partIdName+"\')\"></a>" +
  60. "</td>" +
  61. "</td>" +
  62. "</tr>" +
  63. "</table>";
  64.  
  65. document.getElementById(partName).appendChild(partdiv);
  66.  
  67. <!---Allows us to remove multiple fields--->
  68. function removetheElement(divNum) {
  69.   var d = document.getElementById('partsInput');
  70.   var olddiv = document.getElementById(divNum);
  71.  olddiv.parentNode.removeChild(olddiv);
  72. }
  73.  
  74. </script>
Thank you in advance,

Rach
Oct 14 '08 #1
Share this Question
Share on Google+
58 Replies


acoder
Expert Mod 15k+
P: 16,027
Since you can have multiple parts per serial, you need to use the part-counts in each serial to loop over (as you've done with serial-count) to add parts to each serial.
Oct 14 '08 #2

100+
P: 769
Since you can have multiple parts per serial, you need to use the part-counts in each serial to loop over (as you've done with serial-count) to add parts to each serial.

Hey Acoder,

So would something like this work?

used for serial and description
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 followdate      = Form["followdate_" & machineCount]>
  18.  <CFSET onsite          = Form["onsite_" & machineCount]>
  19.  <CFSET numonsite       = Form["numonsite_" & machineCount]>--->
  20.  
  21. <cfquery name="serial" datasource="CustomerSupport">
  22.    exec usp_CS_Insertserial 
  23.      <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  24.      '#Form.ID#',
  25.      <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
  26.      <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
  27.      <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
  28.      <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
  29.      <cfqueryparam value="#resdate#">,
  30.      <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
  31.      <cfqueryparam value="#vertifidate#">,
  32.      <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
  33.      <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">,
  34.      <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  35.    </cfquery>
  36.  
  37. <!---Inserts information into notes_descr table.--->
  38. <cfquery name="description" datasource="CustomerSupport">
  39.     exec usp_CS_Insertdescription
  40.    <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  41.    '#Form.ID#',
  42.    <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
  43.    '#Form.fk_addedBy#'
  44. </cfquery>
  45. </CFLOOP>
  46. </CFIF>
  47.  



used for the parts section
Expand|Select|Wrap|Line Numbers
  1. <!---Inserts parts information into parts table.--->
  2. <!---because it is a bit we don't use 'ticks' around defective for parts table--->
  3. <CFIF REQUEST_METHOD EQ "POST">
  4. <CFSET machineListLen = listLen(Form.partscount)>
  5. <CFLOOP from="1" to="#machineListLen#" index="machineCount">
  6.  <CFSET hcpn            = Form["hcpn_" & machineCount]>
  7.  <CFSET partsreturn     = Form["partsreturn_" & machineCount]>
  8.  <CFSET defective       = Form["defective_" & machineCount]>
  9.  
  10.  
  11. <cfquery name="parts" datasource="CustomerSupport">
  12.     exec usp_CS_Insertparts
  13.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  14.     '#Form.ID#',
  15.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  16.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  17.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
  18. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  19. </cfquery>
  20. </CFLOOP>
  21. </CFIF>

Thank you,
Rach
Oct 14 '08 #3

acoder
Expert Mod 15k+
P: 16,027
That wouldn't necessarily work because there are multiple counts for parts, so you would need to get each parts count and loop over that number of times for each serial.
Oct 14 '08 #4

100+
P: 769
That wouldn't necessarily work because there are multiple counts for parts, so you would need to get each parts count and loop over that number of times for each serial.
Hey Acoder,

I hate to say it but i am completely lost by what you mean. This is how i have it right now

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.  
  50. <!---Inserts parts information into parts table.--->
  51. <!---because it is a bit we don't use 'ticks' around defective for parts table--->
  52. <cfquery name="parts" datasource="CustomerSupport">
  53.     exec usp_CS_Insertparts
  54.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  55.     '#Form.ID#',
  56.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  57.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  58.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
  59. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  60. </cfquery>
  61. </CFLOOP>
  62. </CFIF>
Are you saying to do 2 cfloops one for serial (Iike i have now) an then add another cfloop for parts? would i then only put it around the parts section or all of the code like above? just confused on what i need to get

Thank you,
Rach
Oct 14 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Yes, two cfloops and the second one only around parts looping from 1 to partscount1,2,3,etc. where 1,2,3 would be the current serial count.
Oct 14 '08 #6

100+
P: 769
Yes, two cfloops and the second one only around parts looping from 1 to partscount1,2,3,etc. where 1,2,3 would be the current serial count.
Hey Acoder,

so would i do the loop like this? was not sure what to put in to=.

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="partc">
  2. <cfquery name="parts" datasource="CustomerSupport">
  3.     exec usp_CS_Insertparts
  4.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  5.     '#Form.ID#',
  6.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  7.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
  9. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  10. </cfquery>
  11. </cfloop>
Thank you,
Rach
Oct 14 '08 #7

acoder
Expert Mod 15k+
P: 16,027
The "to" attribute would need to be set to the parts count variables, e.g. #partscount# where #partscount# could be set in the line before to the form variable passed from the client-side.
Oct 14 '08 #8

100+
P: 769
The "to" attribute would need to be set to the parts count variables, e.g. #partscount# where #partscount# could be set in the line before to the form variable passed from the client-side.
Hey Acoder,

Ok i am lost in my serial function i have this line

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' value='0' id='"+partc+"' \>" +
do i need to give this line a name an then put whatever the name i put for this line in the "to" for the cfloop?

Thank you,
Rach
Oct 14 '08 #9

acoder
Expert Mod 15k+
P: 16,027
Yes, it also needs a name. Note that partc is not the ID/name - it's the variable holding the string value which you set earlier in the function.
Oct 14 '08 #10

100+
P: 769
Yes, it also needs a name. Note that partc is not the ID/name - it's the variable holding the string value which you set earlier in the function.
Hey Acoder,

Ok so like this

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' value='0' name="partscount" id="partscount" value='"+partc+"' \>" +
an then do i use the name in the "to" on my cfloop?

Thank you,
Rach
Oct 14 '08 #11

acoder
Expert Mod 15k+
P: 16,027
No, don't set the name/ID to "partscount". Set it to partc as you had before (same for both ID and name. Note also that you now have two values (which is also incorrect). You need something like:
Expand|Select|Wrap|Line Numbers
  1.  name='"+partc+"' id='"+partc+"'
Oct 14 '08 #12

100+
P: 769
No, don't set the name/ID to "partscount". Set it to partc as you had before (same for both ID and name. Note also that you now have two values (which is also incorrect). You need something like:
Expand|Select|Wrap|Line Numbers
  1.  name='"+partc+"' id='"+partc+"'
Hey Acoder,

So like this

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='"+partc+"' id='"+partc+"' value='"+partc+"' \>" +
an then for the to in the cfloop i call '"+partc+"' correct?

Thank you,
Rach
Oct 14 '08 #13

acoder
Expert Mod 15k+
P: 16,027
The value has to be a number, 0 initially. Look at what partc is set to (look earlier in the function, not sure which line). That's what Coldfusion will see. To see what this turns out in the browser, check the generated source in the browser and you will see that the name and ID are set to "partscount1" or "partscount2", etc. depending on the serial number. This is what is required in the cfloop.
Oct 14 '08 #14

100+
P: 769
The value has to be a number, 0 initially. Look at what partc is set to (look earlier in the function, not sure which line). That's what Coldfusion will see. To see what this turns out in the browser, check the generated source in the browser and you will see that the name and ID are set to "partscount1" or "partscount2", etc. depending on the serial number. This is what is required in the cfloop.
Hey Acoder,

So your saying it needs 'partscount'+count (which is what partc is set to) in the "to" in the cfloop ?

Thank you,
Rach
Oct 14 '08 #15

acoder
Expert Mod 15k+
P: 16,027
Yes, with 'count' being the serial number.
Oct 14 '08 #16

100+
P: 769
Yes, with 'count' being the serial number.
Hey Acoder,

So something like this correct?

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="'partscount'+serialcount">
  2. <cfquery name="parts" datasource="CustomerSupport">
  3.     exec usp_CS_Insertparts
  4.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  5.     '#Form.ID#',
  6.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  7.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
  9. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  10. </cfquery>
  11. </cfloop>
Thank you,
Rach
Oct 14 '08 #17

acoder
Expert Mod 15k+
P: 16,027
Not quite. It'd have to be a Coldfusion form variable like the serial count for the first loop.
Oct 15 '08 #18

100+
P: 769
Not quite. It'd have to be a Coldfusion form variable like the serial count for the first loop.
Hey Acoder,

So what would i use because i don't have any hidden fields in the parts function.

an all i have in the serial function is

Expand|Select|Wrap|Line Numbers
  1. "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0' \>" +
  2. "<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
an then is what i have for the html
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value="0" id="theValue" name="theValue"/>
Thank you,
Rach
Oct 15 '08 #19

acoder
Expert Mod 15k+
P: 16,027
You don't need any in the parts function because the one(s) in the serial function is/are the count(s) for parts. What I suggest you do is turn on debugging so you can see what's being passed to your Coldfusion script. You should see all the form element names and values.
Oct 15 '08 #20

100+
P: 769
You don't need any in the parts function because the one(s) in the serial function is/are the count(s) for parts. What I suggest you do is turn on debugging so you can see what's being passed to your Coldfusion script. You should see all the form element names and values.
Hey Acoder,

So are you saying i need to pass serialcount in my cfloop?

Thank you,
Rach
Oct 15 '08 #21

acoder
Expert Mod 15k+
P: 16,027
The serialcount would be required to construct the form element name:
form["partscount" & serialcount]
Oct 15 '08 #22

100+
P: 769
The serialcount would be required to construct the form element name:
form["partscount" & serialcount]
Hey Acoder,

When i tried this i got the error

Attribute TO in tag CFLOOP has an invalid value

Cannot convert form['partscount'&serialcount] to number.

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="form['partscount'&serialcount]">
an when i tried this it was having issues with the "

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="form["partscount"&serialcount]">
Thank you,
Rach
Oct 15 '08 #23

acoder
Expert Mod 15k+
P: 16,027
That's a Coldfusion variable, so it has to be within ##
Oct 15 '08 #24

100+
P: 769
That's a Coldfusion variable, so it has to be within ##
Hey Acoder,

Does the serialcount or the partscount need to be in ##? an does partscount still need '' around it?


Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="form['partscount' & #serialcount#]">
Thank you,
Rach
Oct 15 '08 #25

acoder
Expert Mod 15k+
P: 16,027
The whole thing: #form[...]#
Oct 15 '08 #26

100+
P: 769
The whole thing: #form[...]#
Hey Acoder,

its having issues with the cfloop. was not earlier for some reason but i am now. it says

Attribute set validation error in tag CFLOOP

The tag has an invalid attribute combination: the most likely attribute combination is

Required attributes: 'FROM,INDEX,TO'. Optional attributes: 'STEP'.

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & serialcount]#">
  2. <cfquery name="parts" datasource="CustomerSupport">
  3.     exec usp_CS_Insertparts
  4.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  5.     '#Form.ID#',
  6.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  7.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
  9. <!---    <cfquery param value="#submission#" CFSQLType = "CF_SQL_VARCHAR">--->
  10. </cfquery>
  11. </cfloop>
Thank you,
Rach
Oct 15 '08 #27

acoder
Expert Mod 15k+
P: 16,027
You forgot the index attribute - see the first cfloop.
Oct 15 '08 #28

100+
P: 769
You forgot the index attribute - see the first cfloop.
Hey Acoder,

It works perfectly for inserting only one serial and one part. But when i tried more i got the following error
An error occurred while evaluating the expression:


"#form['partscount' & serialcount]#"


Error near line 95, column 27.
--------------------------------------------------------------------------------

The member "PARTSCOUNT1,2" in dimension 1 of object "form" cannot be found. Please, modify the member name.


an well line 95 is the cfloop.

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & serialcount]#" index="machineCount">
  2. <cfquery name="parts" datasource="CustomerSupport">
  3.     exec usp_CS_Insertparts
  4.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  5.     '#Form.ID#',
  6.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  7.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  9.    '#Form.submission#'
  10. </cfquery>
  11. </cfloop>
  12.  
Thank you :),
Rach
Oct 15 '08 #29

acoder
Expert Mod 15k+
P: 16,027
Right, I see. Instead of serialcount, you'll want to use machinecount (the index variable of the first loop).
Oct 15 '08 #30

100+
P: 769
Right, I see. Instead of serialcount, you'll want to use machinecount (the index variable of the first loop).
Hey Acoder,

So like this? does the index need to be removed or put a different name behind index?

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & machinecount]#" index="machineCount">
Thank you,
Rach
Oct 15 '08 #31

acoder
Expert Mod 15k+
P: 16,027
Yes, you should use a different name to avoid problems.
Oct 15 '08 #32

100+
P: 769
Yes, you should use a different name to avoid problems.
Hey Acoder,

I did this

Expand|Select|Wrap|Line Numbers
  1. <!---Inserts parts information into parts table.--->
  2. <!---because it is a bit we don't use 'ticks' around defective for parts table--->
  3. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  4. <cfquery name="parts" datasource="CustomerSupport">
  5.     exec usp_CS_Insertparts
  6.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  7.     '#Form.ID#',
  8.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  9.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  10.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  11.    '#Form.submission#'
  12. </cfquery>
  13. </cfloop>
but i am getting the following error

An error occurred while evaluating the expression:


hcpn = Form["hcpn_" & machineCount]


Error near line 60, column 8.
--------------------------------------------------------------------------------

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


an the error comes from in the cfset area

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.  
  50. <!---Inserts parts information into parts table.--->
  51. <!---because it is a bit we don't use 'ticks' around defective for parts table--->
  52. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  53. <cfquery name="parts" datasource="CustomerSupport">
  54.     exec usp_CS_Insertparts
  55.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  56.     '#Form.ID#',
  57.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  58.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  59.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  60.    '#Form.submission#'
  61. </cfquery>
  62. </cfloop>
  63. </CFLOOP>
  64. </CFIF>
  65.  
Thank you,
Rach
Oct 15 '08 #33

acoder
Expert Mod 15k+
P: 16,027
The variables corresponding to the parts query should be in the second cfloop. Check what you've named the parts fields.
Oct 15 '08 #34

100+
P: 769
The variables corresponding to the parts query should be in the second cfloop. Check what you've named the parts fields.
Hey Acoder,

i checked the fields an there named correctly unless instead of hcpn it needs to be hcpn_

here is what i got in the javascript for it

Expand|Select|Wrap|Line Numbers
  1. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
  2. "<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
  3. "<tr>" +
  4. "<td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;<input type='text' name='hcpn_" + count + "' style='margin:0px'></td>" +
  5. "<td class='red'>" +
  6. "Parts been returned* " +
  7. "<input type='checkbox' name='partsreturn_" + count +"' value='1'/>" +
  8. "</td>" +
  9. "<td>" +
  10. "<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"' value='1'/></td>" +
  11. "</td>" +
  12. "</tr>" +
  13. "</table>" +
and here is what i have for the submitting

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  2.  <CFSET hcpn            = Form["hcpn_" & machineCount]>
  3.  <CFSET partsreturn     = Form["partsreturn_" & machineCount]>
  4.  <CFSET defective       = Form["defective_" & machineCount]>
  5. <cfquery name="parts" datasource="CustomerSupport">
  6.     exec usp_CS_Insertparts
  7.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     '#Form.ID#',
  9.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  10.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  12.    '#Form.submission#'
  13. </cfquery>
  14. </cfloop>
Thank you,
Rach
Oct 15 '08 #35

acoder
Expert Mod 15k+
P: 16,027
In that loop, for the parts query variables, you should replace machineCount with ps (the index variable).
Oct 15 '08 #36

100+
P: 769
In that loop, for the parts query variables, you should replace machineCount with ps (the index variable).
Hey Acoder,

It worked, but didn't work. It inserted into the table but not how it needs to insert.
When it inserted instead of creating a separate record for each part. It made 2 records but put the information from both parts in both records

example

here is how it looks

record 1: hc_part no: test 1 p, test 2 p
record 2: hc_part no: test 1 p, test 2 p

an how it needs to look
record 1: hc_part no: test 1 p
record 2: hc_part no: test 2 p

do i need to add this line to the top of parts?

Expand|Select|Wrap|Line Numbers
  1. <CFIF REQUEST_METHOD EQ "POST">
here is what i have for parts

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  2.  <CFSET hcpn            = Form["hcpn_" & ps]>
  3.  <CFSET partsreturn     = Form["partsreturn_" & ps]>
  4.  <CFSET defective       = Form["defective_" & ps]>
  5. <cfquery name="parts" datasource="CustomerSupport">
  6.     exec usp_CS_Insertparts
  7.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     '#Form.ID#',
  9.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  10.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  12.    '#Form.submission#'
  13. </cfquery>
  14. </cfloop>
Thank you :),
Rach
Oct 15 '08 #37

acoder
Expert Mod 15k+
P: 16,027
Does this affect just hcpn or all three variables?
Oct 15 '08 #38

100+
P: 769
Does this affect just hcpn or all three variables?
Hey Acoder,

It affects all 3 fields

Thank you,
Rach
Oct 15 '08 #39

acoder
Expert Mod 15k+
P: 16,027
Either check on the client-side (using, say, Firebug) what the generated source is when you have two parts, or turn debugging on and check what's passed through to Coldfusion. Check the names of the parts input fields.

You should turn debugging on anyway if you haven't already done so. On a development machine it should be turned on so you can get useful information about your application.
Oct 16 '08 #40

100+
P: 769
Hey Acoder,

With the debugging for coldfusion i don't have the ability to turn it on because its controlled by the main web developer. Basically the errors i get are what i get.

but i opened up firebug an i didn't see anything that stands out. Basically here is what i get when i have to parts though.this is looking at the html of it.

dynamic1input
part1name1

dynamic2input
part1name2

an i noticed in the database that it puts the hcpn field like this part 1,part 2
however for all the other fields it only puts one value in those.

But here is what i have in full

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 followdate      = Form["followdate_" & machineCount]>
  18.  <CFSET onsite          = Form["onsite_" & machineCount]>
  19.  <CFSET numonsite       = Form["numonsite_" & machineCount]>--->
  20.  
  21. <cfquery name="serial" datasource="CustomerSupport">
  22.    exec usp_CS_Insertserial 
  23.      <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  24.      '#Form.ID#',
  25.      <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
  26.      <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
  27.      <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
  28.      <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
  29.      <cfqueryparam value="#resdate#">,
  30.      <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
  31.      <cfqueryparam value="#vertifidate#">,
  32.      <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
  33.      <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">,
  34.      <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">
  35.    </cfquery>
  36.  
  37. <!---Inserts information into notes_descr table.--->
  38. <cfquery name="description" datasource="CustomerSupport">
  39.     exec usp_CS_Insertdescription
  40.    <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  41.    '#Form.ID#',
  42.    <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
  43.    '#Form.fk_addedBy#'
  44. </cfquery>
  45.  
  46.  
  47. <!---Inserts parts information into parts table.--->
  48. <!---because it is a bit we don't use 'ticks' around defective for parts table--->
  49. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  50.  <CFSET hcpn            = Form["hcpn_" & ps]>
  51.  <CFSET partsreturn     = Form["partsreturn_" & ps]>
  52.  <CFSET defective       = Form["defective_" & ps]>
  53. <cfquery name="parts" datasource="CustomerSupport">
  54.     exec usp_CS_Insertparts
  55.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  56.     '#Form.ID#',
  57.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  58.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  59.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  60.    '#Form.submission#'
  61. </cfquery>
  62. </cfloop>
  63. </CFLOOP>
  64. </CFIF>
Thank you,
Rach
Oct 16 '08 #41

acoder
Expert Mod 15k+
P: 16,027
Check the three variables in Firebug by expanding one part (the +) and see the values.

Is there no chance you could ask the main web developer to switch it on for you. Surely it'd make things easier.
Oct 16 '08 #42

100+
P: 769
Check the three variables in Firebug by expanding one part (the +) and see the values.

Is there no chance you could ask the main web developer to switch it on for you. Surely it'd make things easier.
Hey Acoder,

Well with the main developer, i can never get a hold of him. We was suppose to go over something a week an a half ago an still haven't. But i did notice something looking for the 3 variables.

dynamic1input has this
Expand|Select|Wrap|Line Numbers
  1. <input id="partscount1" type="hidden" value="1" name="partscount1"/>
  2. <input id="serialcount" type="hidden" value="1" name="serialcount"/>
dynamic2input

Expand|Select|Wrap|Line Numbers
  1. <input id="partscount2" type="hidden" value="1" name="partscount2"/>
  2. <input id="serialcount" type="hidden" value="2" name="serialcount"/> 
an when i looked under part1Name1 and part1Name2 all the fields had hcpn_1 partsreturn_1 and defective_1. I don't know if that means anything but thought i would point it out.

Thank you,
Rach
Oct 16 '08 #43

acoder
Expert Mod 15k+
P: 16,027
That will be the problem. All parts variables have the same name, so when passed to Coldfusion, it's passed as a list which is what's being added to the database.

What you'll need to do is make all parts fields unique. You can do that by adding the serial count to the name, e.g. by adding "_" + serialcount, then modifying the Coldfusion to get each unique parts field.
Oct 16 '08 #44

100+
P: 769
That will be the problem. All parts variables have the same name, so when passed to Coldfusion, it's passed as a list which is what's being added to the database.

What you'll need to do is make all parts fields unique. You can do that by adding the serial count to the name, e.g. by adding "_" + serialcount, then modifying the Coldfusion to get each unique parts field.
Hey Acoder,

I get what your saying, just not sure on the naming part. So would something like this work?

Expand|Select|Wrap|Line Numbers
  1. <input type='text' name='hcpn_" + count + "_"+serialcount"' style='margin:0px'>
Thank you,
Rach
Oct 16 '08 #45

acoder
Expert Mod 15k+
P: 16,027
Almost - you forgot the + after serialcount.
Oct 16 '08 #46

100+
P: 769
Almost - you forgot the + after serialcount.
Hey Acoder,

Does it need to be serialcount or serialno? because it says serialcount is undefined. here is what i have

Expand|Select|Wrap|Line Numbers
  1. "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
  2. "<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
  3. "<tr>" +
  4. "<td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;" +
  5. "<input type='text' name='hcpn_" + count + "_"+serialcount+"' style='margin:0px'></td>" +
  6. "<td class='red'>" +
  7. "Parts been returned* " +
  8. "<input type='checkbox' name='partsreturn_" + count +"_"+serialcount+"' value='1'>" +
  9. "</td>" +
  10. "<td>" +
  11. "<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"_"+serialcount+"' value='1'>" +
  12. "</td>" +
  13. "</td>" +
  14. "</tr>" +
  15. "</table>";
Thank you,
Rach
Oct 16 '08 #47

acoder
Expert Mod 15k+
P: 16,027
Yes, then it must be serialno, not serialcount.
Oct 16 '08 #48

100+
P: 769
Yes, then it must be serialno, not serialcount.
Hey Acoder,

Ok then in my cfloop would it be like this? or do i need to get serialno in here as well?

Expand|Select|Wrap|Line Numbers
  1. <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
  2.  <CFSET hcpn            = Form["hcpn_" & ps & "_machinecount"]>
  3.  <CFSET partsreturn     = Form["partsreturn_" & ps & "_machinecount"]>
  4.  <CFSET defective       = Form["defective_" & ps & "_machinecount"]>
  5. <cfquery name="parts" datasource="CustomerSupport">
  6.     exec usp_CS_Insertparts
  7.     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
  8.     '#Form.ID#',
  9.     <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
  10.     <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
  11.     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
  12.    '#Form.submission#'
  13. </cfquery>
  14. </cfloop>
Thank you,
Rach
Oct 16 '08 #49

acoder
Expert Mod 15k+
P: 16,027
If you're going to put machinecount in the string, then wrap it in #s or take it out of the string like ps.
Oct 16 '08 #50

58 Replies

Post your reply

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