472,125 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

how to loop through this?

769 512MB
Hey Everyone,

What i am trying to do is show previously entered information. I know i need a loop for this , but i am not sure how to loop through this based on my form appears all in the javascript

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

i was using this after i submitted my form to loop through it. it was used to submit the form fields and also show a print screen on what was previously entered.

Expand|Select|Wrap|Line Numbers
  1. <CFSET machineListLen = listLen(Form.serialcount)>
  2. <CFLOOP from="1" to="#machineListLen#" index="machineCount">
  3.  <CFSET serialnum       = "Form.serialnum_" & machineCount>
  4.  <CFSET modelno         = "Form.modelno_" & machineCount>
  5.  <CFSET producttype     = "Form.producttype_" & machineCount>
  6.  <CFSET softhardware    = "Form.softhardware_" & machineCount>
  7.  <CFSET resolution      = "Form.resolution_" & machineCount>
  8.  <CFSET resdate         = "Form.resdate_" & machineCount>
  9.  <CFSET resvertified    = "Form.resvertified_" & machineCount>
  10.  <CFSET vertifidate     = "Form.vertifidate_" & machineCount>
  11.  <CFSET deptvendor      = "Form.deptvendor_" & machinecount>
  12.  <CFSET hardwarefailure = "Form.hardwarefailure_" & machineCount>
  13.  <CFSET rma             = "Form.rma_" & machineCount>
  14.  <CFSET thedescription  = "Form.thedescription_" & machineCount>
  15.  
  16. #evaluate(modelno)#....an so on.
but i am not sure if i can combine the above with what i have now because i am showing previously entered data an not entering the data.

Thank you for all the help,
Rach
Sep 22 '08
60 5020
bonneylake
769 512MB
It seems as though this line shows the description (line 83):
Expand|Select|Wrap|Line Numbers
  1. <cfloop query="description"><textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name="thedescription_#count#">#description#</textarea></cfloop> 
Is the problem that instead of one description per serial, it's showing all descriptions side by side or is it that multiple descriptions can appear under one serial, but they're just not in the right place?
Hey Acoder,

Yes its showing them but its putting them side by side. It shows multiple descriptions. like for example

serial information 1
description 1 description 2

serial information 2
description 1 description 2

when it needs to be like

serial information 1
description 1

serial information 2
description 2

Thank you,
Rach
Oct 11 '08 #51
acoder
16,027 Expert Mod 8TB
Is description not a field in the serial table? Why have you got a separate query for description?
Oct 11 '08 #52
bonneylake
769 512MB
Is description not a field in the serial table? Why have you got a separate query for description?
Hey Acoder,

No the description is not in the serial table its in the description table. An i had forgotten about that till i looked at it yesterday when i added 2 descriptions.

Thank you,
Rach
Oct 11 '08 #53
acoder
16,027 Expert Mod 8TB
Is it one description per serial or could you have more than one per serial? What kind of query are you using to retrieve the descriptions?
Oct 12 '08 #54
bonneylake
769 512MB
Is it one description per serial or could you have more than one per serial? What kind of query are you using to retrieve the descriptions?
Hey Acoder,

Its definitely one description per serial. an this is what i am using to retrieve the description

Expand|Select|Wrap|Line Numbers
  1. <!---Shows what was previously entered into description table--->
  2. <cfquery name="description" datasource="CustomerSupport">
  3.         SELECT fk_serialNo,fk_ticketNo,description
  4.          FROM dbo.tbl_CS_notes_descr
  5.          WHERE fk_ticketNo = #URL.pk_ticketID#
  6. </cfquery>
Thank you,
Rach
Oct 12 '08 #55
acoder
16,027 Expert Mod 8TB
If it's always only one, why not store in the serial table? If that's not an option, make a join query when getting the serial, so the description is also included and you don't need two separate queries.
Oct 13 '08 #56
bonneylake
769 512MB
If it's always only one, why not store in the serial table? If that's not an option, make a join query when getting the serial, so the description is also included and you don't need two separate queries.
Hey Acoder,

That is a brillant idea (why didn't i think of that!). An well i tried it but i am having a weird problem.

This is what its doing

serial number: 963
description: this is the description

serial number: 999
description: this is the description

serial number: 963
description: this is the second description

serial number: 999
description: this is the second description

an it needs to be

serial number: 963
description: this is the description

serial number: 999
description: this is the second description

here is what i have for the cfquery. it has the serial an description in it now.

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="serial" datasource="CustomerSupport">
  2.         SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
  3.        resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
  4.         dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
  5.         FROM dbo.tbl_CS_serial, dbo.tbl_CS_notes_descr
  6.         WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
  7. </cfquery>

that an inbetween the div i had this, i took the cfloop off from around description.

Expand|Select|Wrap|Line Numbers
  1. <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
  2. <tr>
  3. <td id="paddingformutli">
  4. Description:&nbsp;&nbsp;
  5. </td>
  6. <td class="descriptionmoveinmulti">
  7. ( You may enter up to 500 characters. )
  8. <br>
  9. <cfloop query="description"><textarea maxlength="500" onkeyup="return ismaxlength(this)" onkeydown="return ismaxlength(this)" rows="4" cols="60" name="thedescription_#count#">#description#</textarea></cfloop> 
  10. </td>
  11. </tr>
  12. </table>
but besides that everything else is the same so i am not sure why its putting the results twice. Any ideas?

Thank you,
Rach
Oct 13 '08 #57
acoder
16,027 Expert Mod 8TB
That's because you've joined the query without removing the duplicates by matching up the IDs. See left join.
Oct 13 '08 #58
bonneylake
769 512MB
That's because you've joined the query without removing the duplicates by matching up the IDs. See left join.
Hey Acoder,

I read it but i think i got something confused.do i need to do to each field dbo.tbl_CS_serial.pka_serialNo?

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="serial" datasource="CustomerSupport">
  2.         SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
  3.        resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
  4.         dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
  5.         FROM dbo.tbl_CS_serial
  6.         LEFT JOIN dbo.tbl_CS_notes_descr
  7.         ON pkb_fk_ticketNo=fk_ticketNo
  8.         WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
  9. </cfquery>
Thank you,
Rach
Oct 13 '08 #59
bonneylake
769 512MB
Hey Acoder,

I figured out what i did wrong. Here is what the results where.

Expand|Select|Wrap|Line Numbers
  1. <!---Shows what was previously entered into serial and description table--->
  2. <cfquery name="serial" datasource="CustomerSupport">
  3.         SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
  4.        resolution,resolution_date,verification_date,rma_data,type_hardware_failure,
  5.         dept_responsibility,resolution_verified_by,fk_serialNo,fk_ticketNo,description
  6.         FROM dbo.tbl_CS_serial
  7.         LEFT JOIN dbo.tbl_CS_notes_descr
  8.         ON dbo.tbl_CS_serial.pkb_fk_ticketNo=dbo.tbl_CS_notes_descr.fk_ticketNo and
  9.         dbo.tbl_CS_serial.pka_serialNo=dbo.tbl_CS_notes_descr.fk_serialNo
  10.         WHERE pkb_fk_ticketNo = #URL.pk_ticketID# and fk_ticketNo = #URL.pk_ticketID#
  11.         ORDER BY pkb_fk_ticketNo
  12. </cfquery>
Thank you again for all the help!!! :)

Rach
Oct 13 '08 #60
acoder
16,027 Expert Mod 8TB
Good work, though I'm not sure about the where clause. I think one of them is probably not needed.
Oct 13 '08 #61

Post your reply

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

Similar topics

reply views Thread by Charles Alexander | last post: by
6 posts views Thread by Ravi | last post: by
43 posts views Thread by Gremlin | last post: by
11 posts views Thread by Roman Töngi | last post: by
2 posts views Thread by Alex | last post: by
63 posts views Thread by Aaron Ackerman | last post: by
3 posts views Thread by numlock00 | last post: by
reply views Thread by leo001 | last post: by

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

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