home *** CD-ROM | disk | FTP | other *** search
/ Cool Page Magazine 16 / CoolPage_16.iso / dynadb / codes / prodlist.cfm < prev    next >
Text File  |  1998-01-29  |  6KB  |  199 lines

  1. <html>
  2. <head>
  3. <title>┐∩╛▄│f¬½</title>
  4. </head>
  5.  
  6. <cfset type_rec=ArrayNew(2)>
  7. <cfset product_rec=ArrayNew(2)>
  8. <cfset obj_name=ArrayNew(2)>
  9. <cfset all_prod_id="">
  10. <cfset v=0>
  11. <cfset k=0>
  12.  
  13. <cfquery name="GetType" datasource="dynamic database">
  14.     select * from prodtype
  15. </cfquery>
  16.  
  17. <cfoutput query="GetType">
  18.     <cfset k=k+1>
  19.     <cfset type_rec[k][1]=#type_code#>
  20.     <cfset type_rec[k][2]=#type_name#>
  21. </cfoutput>
  22.  
  23. <BODY background="paper12l.jpg">
  24. <h4>║⌠ ╡╕ «╔ ÑN ╣q ╕ú ╣s Ñ≤<br>
  25. ╜╨ ┐∩ ╛▄ ⌐╥ ¡n ┴╩ ╢R ¬║ ╣q ╕ú ▓╒ Ñ≤ íC ¡Y ╖Q ¬╛ ╣D ╗∙ «µ íA ╜╨ ½÷ ñU ¡╢ Ñ╜ ¬║ íu ¡p ║Γ ╗∙ ┐· ív
  26. </h4><br>
  27.  
  28. <cfform name="ProductInfo" action="Calcu.cfm">
  29. <cfloop index="m" from="1" to="#k#">
  30.  
  31.  
  32. <!--------------------------------------------------------------------------------
  33. ñU¡▒│o¼q Java Script ¼O¿C╖φÑ╬ñß½÷ñUcheck box«╔íAªp¬G╝╞╢q─µª∞¼O 0 ⌐╬ñ░╗≥│ú¿Sª│«╔íA
  34. ┤N▒N─µª∞│]¼░ 1
  35. --------------------------------------------------------------------------------->
  36.  
  37. <cfoutput>
  38. <script language="JavaScript">
  39. <cfset function_name="SetText" & #m#>
  40. function #function_name#()
  41. {
  42.     <cfset text_name= "qty" & #m#>
  43.     <cfset check_name="check_box" & #m#>
  44.     if(document.ProductInfo.#check_name#.checked)
  45.     {        
  46.         if(document.ProductInfo.#text_name#.value=="0"||document.ProductInfo.#text_name#.value=="")
  47.             document.ProductInfo.#text_name#.value="1"
  48.     }
  49. }
  50. </script>
  51. </cfoutput>
  52.  
  53.  
  54.     <cfquery name="GetProduct" datasource="dynamic database">
  55.         select * from product 
  56.         where type='#type_rec[m][1]#'
  57.         order by product_name
  58.     </cfquery>
  59.  
  60.     <cfoutput query="GetProduct">
  61.         <cfset all_prod_id=all_prod_id & "#chr(168)#" & "#prod_id#">
  62.     </cfoutput>    
  63.  
  64.     <cfif GetProduct.RecordCount is not 0>
  65.  
  66.     <cfset boxname="check_box" & #m#>
  67.     <CFINPUT TYPE="checkbox"
  68.             NAME=#boxname#
  69.         onClick=#function_name#()
  70.             CHECKED="No"><cfoutput>#type_rec[m][2]#</cfoutput>
  71.     <br>
  72.  
  73.     <cfset gridname="grid_no" & #m#>     
  74.         <CFGRID    NAME=#gridname# 
  75.         height="150" 
  76.         width="400"
  77.         QUERY="GetProduct" 
  78.         SELECTMODE="row" 
  79.         selected="1"
  80.         appendkey="yes">
  81.     <CFGRIDCOLUMN NAME="prod_id" display="no">    
  82.     <CFGRIDCOLUMN NAME="product_name" header="│f¬½ªW║┘">
  83.     <CFGRIDCOLUMN NAME="cost" header="╗∙┐·">
  84.     <CFGRIDCOLUMN NAME="type" display="no">    
  85.  
  86.         </CFGRID>
  87.  
  88.     <br>
  89.     <cfset text_name="qty" & #m#>
  90.     ▒²┴╩╝╞╢qíG<CFINPUT TYPE="text" 
  91.             NAME="#text_name#"
  92.             VALUE="0" 
  93.             REQUIRED="no" 
  94.             VALIDATE="integer" 
  95.             MESSAGE="#type_rec[m][2]#¬║╝╞╢qª│╗~íA╜╨┐ΘñJÑ┐╛π╝╞"
  96.             SIZE="10"
  97.             MAXLENGTH="3">
  98.     <br>
  99.     <hr>
  100.     <cfset v=v+1>
  101.     <cfset obj_name[v][1]="check_box" & #m#>
  102.     <cfset obj_name[v][2]="grid_no" & #m#>
  103.     <cfset obj_name[v][3]="#type_rec[m][2]#">
  104.     <cfset obj_name[v][4]="qty" & #m#>
  105.  
  106.     </cfif>
  107. </cfloop>
  108.  
  109.  
  110. <input type="button" name="calculate" value="¡p║Γ╗∙┐·" onClick="SumPrice()">
  111. ┴`¡╚íGHK$<input type="text" name="totalprice" maxlength=7><br>
  112. <input type="reset" value="▓M░ú─µª∞">
  113. <hr>
  114.  
  115. <INPUT TYPE="Submit" VALUE="¡q┴╩" onClick="SumPrice()">
  116. <input type="hidden" name="selected_id">
  117. <input type="hidden" name="selected_qty">
  118. </cfform>
  119. </body>
  120. </html>
  121.  
  122.  
  123. <!-----------------------------------------------------------------------------------
  124. ñU¡▒│o¼q Java Script ╖|¡p║Γ⌐╥┐∩¿·¬║│f¬½┴`¡╚íA¿├└╦¼dñ@ñUÑ╬ñߪ│¿Sª│Ñ╟┐∙
  125. ------------------------------------------------------------------------------------>
  126.  
  127. <script language="JavaScript">
  128. function SumPrice()
  129. {
  130.  
  131. var GridContent=""
  132. TotalPrice=0
  133. CheckedTerms=0
  134. product_selected=""
  135. qty_selected=""
  136. grid_selected=""
  137.  
  138. id_selected=""
  139.  
  140. _CF_checkProductInfo(document.ProductInfo)
  141. <cfloop index="counter" from="1" to="#v#">
  142. <cfoutput>
  143. if (document.ProductInfo.#obj_name[counter][1]#.checked)
  144.     {
  145.     <!-----------------------------------------------------------------
  146.     _CF_getGrid ╖|┐ΘÑX íu_CFGRID__COLUMN__=XXX;__CFGRID__DATA__=XXXív
  147.     ------------------------------------------------------------------->
  148.  
  149.     GridContent=_CF_getGrid(document.#obj_name[counter][2]#)
  150.  
  151.     
  152.  
  153.     <!-----------------------------------------------------------------
  154.         ¡Y╖Q¬╛╣D _CF_getGrid ╣Ω╗┌¬║┐ΘÑXíAÑiÑH░⌡ªµñUñ@ªµ¬║╗yÑy
  155.     ------------------------------------------------------------------>
  156.     <!-----------------------------------------------------------------
  157.         alert(GridContent)
  158.     ------------------------------------------------------------------>
  159.  
  160.     if(GridContent=="")
  161.     {
  162.         alert("ºA┐∩¿·ñF#obj_name[counter][3]#íAª²¼O┴┘¿S┐∩¿·│f¬½")
  163.     }
  164.     else
  165.     {
  166.         Quantity=parseInt(document.ProductInfo.#obj_name[counter][4]#.value)
  167.         if(Quantity==0)
  168.         {
  169.             alert("#obj_name[counter][3]#¬║╝╞╢qñú▒o¼░╣s")
  170.         }
  171.         else
  172.         {
  173.             CostBeginPos=GridContent.indexOf("__CFGRID__COLUMN__=cost; __CFGRID__DATA__=")+("__CFGRID__COLUMN__=cost; __CFGRID__DATA__=").length
  174.             CostEndPos=GridContent.indexOf("__CFGRID__COLUMN__=type;")-2
  175.             Price=parseInt(GridContent.substring(CostBeginPos, CostEndPos))        
  176.  
  177.             TotalPrice=TotalPrice+Price*Quantity
  178.  
  179.             pattern="__CFGRID__COLUMN__=prod_id; __CFGRID__DATA__="
  180.             idBeginPos=GridContent.indexOf(pattern)+(pattern).length
  181.             idEndPos=GridContent.indexOf("__CFGRID__COLUMN__=product_name;")-2
  182.             id_here=GridContent.substring(idBeginPos, idEndPos)
  183.             id_selected=id_selected+"#chr(168)#"+id_here
  184.  
  185.             qty_selected=qty_selected + "#chr(168)#" + Quantity
  186.             CheckedTerms++
  187.         }
  188.     }
  189. }
  190. </cfoutput>
  191. </cfloop>
  192.  
  193. document.ProductInfo.totalprice.value=TotalPrice    
  194. document.ProductInfo.selected_id.value=id_selected
  195. document.ProductInfo.selected_qty.value=qty_selected
  196.  
  197. }
  198. </script>
  199.