Insert Multiple Parts Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #46
    Almost - you forgot the + after serialcount.

    Comment

    • bonneylake
      Contributor
      • Aug 2008
      • 769

      #47
      Originally posted by acoder
      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

      Code:
      "<table class='zpExpandedTable' id='resoltable' cellpadding='1' cellspacing='0' >" +
      "<th class='sectiontitle' colspan='7'>Parts Information "+ count +" Serial Information "+serialno+"</th>" +
      "<tr>" +
      "<td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;" +
      "<input type='text' name='hcpn_" + count + "_"+serialcount+"' style='margin:0px'></td>" +
      "<td class='red'>" +
      "Parts been returned* " +
      "<input type='checkbox' name='partsreturn_" + count +"_"+serialcount+"' value='1'>" +
      "</td>" +
      "<td>" +
      "<td class='indent'>Defective<input type='checkbox' name='defective_" + count +"_"+serialcount+"' value='1'>" +
      "</td>" +
      "</td>" +
      "</tr>" +
      "</table>";
      Thank you,
      Rach

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #48
        Yes, then it must be serialno, not serialcount.

        Comment

        • bonneylake
          Contributor
          • Aug 2008
          • 769

          #49
          Originally posted by acoder
          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?

          Code:
          <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
           <CFSET hcpn            = Form["hcpn_" & ps & "_machinecount"]>
           <CFSET partsreturn     = Form["partsreturn_" & ps & "_machinecount"]>
           <CFSET defective       = Form["defective_" & ps & "_machinecount"]>
          <cfquery name="parts" datasource="CustomerSupport">
              exec usp_CS_Insertparts
              <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
              '#Form.ID#',
              <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
              <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
              <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
             '#Form.submission#'
          </cfquery>
          </cfloop>
          Thank you,
          Rach

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #50
            If you're going to put machinecount in the string, then wrap it in #s or take it out of the string like ps.

            Comment

            • bonneylake
              Contributor
              • Aug 2008
              • 769

              #51
              Originally posted by acoder
              If you're going to put machinecount in the string, then wrap it in #s or take it out of the string like ps.
              Hey Acoder,

              I think i might have to do it the way you aid with the ps because i got this

              Error Diagnostic Information

              An error occurred while evaluating the expression:

              partsreturn = Form["partsretur n_" & ps & "_#machinecount #"]

              Error near line 94, column 8.

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

              an this is what i have
              Code:
              <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
               <CFSET hcpn            = Form["hcpn_" & ps & "_#machinecount#"]>
               <CFSET partsreturn     = Form["partsreturn_" & ps & "_#machinecount#"]>
               <CFSET defective       = Form["defective_" & ps & "_#machinecount#"]>
              <cfquery name="parts" datasource="CustomerSupport">
                  exec usp_CS_Insertparts
                  <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                  '#Form.ID#',
                  <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                  <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                  <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
                 '#Form.submission#'
              </cfquery>
              </cfloop>
              but if i was going to do it the other way would i create another cfloop or would i do something like a cfset?

              Thank you,
              Rach

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #52
                No, what you have is correct, though the alternative would be:
                Code:
                Form["partsreturn_" & ps & "_" & machinecount]
                From the error message, it seems that hcpn is OK, but partsreturn isn't. Check again what the field names/values being passed are.

                Comment

                • bonneylake
                  Contributor
                  • Aug 2008
                  • 769

                  #53
                  Originally posted by acoder
                  No, what you have is correct, though the alternative would be:
                  Code:
                  Form["partsreturn_" & ps & "_" & machinecount]
                  From the error message, it seems that hcpn is OK, but partsreturn isn't. Check again what the field names/values being passed are.
                  Hey Acoder,

                  Well checked the name for partsreturn an made sure they all match an they do. But i think i know what the problem is. Well when i been testing, for the part i add with the first serial i choose everything. But for the second serial and the first part for it i choose nothing for partsreturn and defective. An it says cant find the object so think its because i am leaving it blank. But thing is i have the following lines in there in case someone does leave it blank

                  Code:
                  <cfparam name="Form.defective" default="0">
                  <cfparam name="Form.partsreturn" default="0">
                  an here is the line its having the problem with

                  Code:
                   <CFSET partsreturn     = Form["partsreturn_" & ps & "_#machinecount#"]>
                  Any ideas?

                  Thank you,
                  Rach

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #54
                    Well, the cfparam doesn't account for the new names. You need to use two cfloops and cfparam all possible part fields. What you could do is put the cfparam just before the cfsets in the second loop.

                    Comment

                    • bonneylake
                      Contributor
                      • Aug 2008
                      • 769

                      #55
                      Originally posted by acoder
                      Well, the cfparam doesn't account for the new names. You need to use two cfloops and cfparam all possible part fields. What you could do is put the cfparam just before the cfsets in the second loop.
                      Hey Acoder,

                      i get the same error. i dont know if this help but it also says

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

                      Code:
                      <cfloop from="1" to="#form['partscount' & machinecount]#" index="ps">
                      <cfparam name="Form.defective" default="0">
                      <cfparam name="Form.partsreturn" default="0">
                       <CFSET hcpn            = Form["hcpn_" & ps & "_#machinecount#"]>
                       <CFSET partsreturn     = Form["partsreturn_" & ps & "_#machinecount#"]>
                       <CFSET defective       = Form["defective_" & ps & "_#machinecount#"]>
                      <cfquery name="parts" datasource="CustomerSupport">
                          exec usp_CS_Insertparts
                          <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                          '#Form.ID#',
                          <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                          <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                          <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">,
                         '#Form.submission#'
                      </cfquery>
                      </cfloop>
                      Thank you,
                      Rach

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #56
                        You can't set only form.partsretur n and form.defective. You need to set the correct name similar to what you have in the cfset: form.partsretur n_#ps#_#machine count#

                        Comment

                        • bonneylake
                          Contributor
                          • Aug 2008
                          • 769

                          #57
                          Originally posted by acoder
                          You can't set only form.partsretur n and form.defective. You need to set the correct name similar to what you have in the cfset: form.partsretur n_#ps#_#machine count#
                          Hey Acoder,

                          It worked!!! Thank you, Thank you!!! But i have another question, if i have questions about printing the in formation, like viewing what was previously entered for parts do i need to create another thread for that? because having a hard time viewing what was previously entered.

                          Thank you so much for all the help!!!!!!!!! :)
                          Rach

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #58
                            Originally posted by bonneylake
                            i have another question, if i have questions about printing the in formation, like viewing what was previously entered for parts do i need to create another thread for that? because having a hard time viewing what was previously entered.
                            Yes, you should create another thread for that problem.
                            Originally posted by bonneylake
                            Thank you so much for all the help!!!!!!!!! :)
                            You're very welcome! I'm glad it's now working.

                            Comment

                            • bonneylake
                              Contributor
                              • Aug 2008
                              • 769

                              #59
                              Originally posted by acoder
                              Yes, you should create another thread for that problem.

                              You're very welcome! I'm glad it's now working.
                              Hey Acoder,

                              i created another thread and here is the thread i started in case anyone is interested.



                              but thank you again for all the help :),
                              Rach

                              Comment

                              Working...