displaying previously entered multiple fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bonneylake
    Contributor
    • Aug 2008
    • 769

    #31
    Originally posted by acoder
    For the add/delete functionality to work, you need to make sure the counts match up. So if there are three, the count has to be 3 and the divs IDs/field names all have to be correct. Check the add functions to see how the naming works and make sure the display from Coldfusion is the same.
    Hey Acoder,

    I get what your saying. I got it removing and adding. But the parts is not counting right.Right now i am testing it on 2 serials both with a part applied to it. An the first serial with the first part counts correctly. But the second part with the second serial does not. It counts 1 an then it goes to 3, no 2 in between. Here is what i have.

    Code:
    <!--- Ticket Information 
           This display the ticket Information--->
        
    <!---<input type="hidden" value="0" id="theValue" />--->
        <div id="dynamicInput"> 
         <!--- All Ticket Information Appears Here--->
         
    
        <!--- Shows what was previously entered for Model No, Product Type, and Type of Hardware Failure  --->
    <cfset count = 0>
    <!---<cfif serial.recordcount is 0>--->
    <cfoutput query="serial">
    <cfset model_no = #model_no#>
    <cfset product_type = #product_type#>
    <cfset type_hardware_failure = #type_hardware_failure#>
    <cfset software_hardware = #software_hardware#>
    <cfset resolution_verified_by = #resolution_verified_by#>
    <cfset dept_responsibility = #dept_responsibility#>
    <cfset count = count + 1>
    <div id="dynamic#count#Input">
    <table class="zpExpandedTable" id="modeltable"> 
    <th class="sectiontitletick" colspan="7">
    Serial Information #count# </th>
    <tr>
    <td id="paddingformultitop">Model No:&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </td>
    <td>
    <select name="modelno_#count#">
    <option value="">Make A Selection</option>
    <cfloop query="models">
    <option value="#model#"<cfif #model# is #model_no#>selected</cfif>>#model#</option>
    </cfloop> 
    </select>
    </td>
    <td>
    &nbsp;&nbsp;&nbsp;&nbsp;Product Type:
    </td>
    <td>
    <select name="producttype_#count#">
    <option value="" selected>No Choice</option>
    <cfloop query="getProdType">
    <option value="#pk_productType#"<cfif #pk_productType# is #product_type#>selected</cfif>>#pk_productType#</option> 
    </cfloop>
    </select>
    </td>
    <td class="red">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type Of Hardware Failure*:
    </td>
    <td>
    <select name="hardwarefailure_#count#">
    <option value="" selected>Make A Selection</option>
    <cfloop query="getHardwareFail">
    <option value="#pk_hardwareFailure#"<cfif #pk_hardwareFailure# is #type_hardware_failure#>selected</cfif>>#pk_hardwareFailure#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    <table>
     
    <!--- Shows what was previously entered for Serial Number and Software/Hardware  --->
    <table class="zpExpandedTable" id="modeltable">
    <tr>
    <td id="paddingformultitop">
    Serial Number:&nbsp;&nbsp;
    <input type="text" name="serialnum_#count#" value="#pka_serialNo#">
    &nbsp;&nbsp;&nbsp;&nbsp;Software/Hardware:&nbsp;&nbsp;
    <select name="softhardware_#count#">
    <option value="" selected>No Choice</option>
    <cfloop query="getSoftHard">
    <option value="#pk_softwareHardware#"<cfif #pk_softwareHardware# is #software_hardware#>selected</cfif>>#pk_softwareHardware#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    </table>
    
    <!--- Shows what was previously entered for Description ---> 
    
    <table class="zpExpandedTable" id="resoltable" cellpadding="3" cellspacing="0">
    <tr>
    <td id="paddingformutli">
    Description:&nbsp;&nbsp;
    </td>
    <td class="descriptionmoveinmulti">
    #description#
    ( You may enter up to 1000 characters. )
    <br>
    <textarea maxlength='1000' onkeyup='return descriptionmaxlength(this)' onkeydown='return descriptionmaxlength(this)'rows='4' cols='60' name="thedescription_#count#"></textarea>
    </td>
    </tr>
    </table>
     
    <!---Shows what was previously entered for Resolution  --->
    
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformutli">
    Resolution:&nbsp;&nbsp;
    </td>
    <td class="resolutionmoveinmulti">
    ( You may enter up to 1500 characters. )
    <br>
    <textarea  maxlength="1500" onkeyup="return resolutionismaxlength(this)" onkeydown="return resolutionismaxlength(this)" rows="4" cols="60" name="resolution_#count#">#resolution#</textarea>
    </td>
    </tr>
    </table>
     
    <!--- Shows what was previously entered for Resolution Date, Current Date (for resolution date) and resolution vertified as effective by  --->
    
    <table class="zpExpandedTable" id="resoldatetab" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformultitop">
    Resolution Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
    </td>
    <td>
    <input type="text" name="resdate_#count#" value="#DateFormat(resolution_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
    <input type="checkbox" name="currentdateresol_#count#" 
    onClick="resdate_#count#.value=fill_date()">
    </td>
    <td>
    Resolution Verified as effective by:&nbsp;&nbsp;
    </td>
    <td>
    <select name="resvertified_#count#">
    <option value="" selected>Make A Selection</option>
    <cfloop query="gettech">
    <option value="#fname# #lname#"<cfif "#fname# #lname#" is #resolution_verified_by#>
    selected</cfif>>#fname# #lname#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    </table>
    <!--- Shows what was previously entered for Vertification Date, Current Date (for vertification date)   --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformultitop">
    Verification Date:&nbsp;(MM/DD/YYYY)&nbsp;&nbsp;
    </td>
    <td class="vertificationmoveinmulti">
    <input type="text" name="vertifidate_#count#" value="#DateFormat(verification_date,'mm/dd/yyyy')#">&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;Current Date:&nbsp;&nbsp;
    <input type="checkbox" name="currentdatevert_#count#" 
    onClick="vertifidate_#count#.value=fill_date()">
    </td>
    </tr>
    </table>
     
    <!--- Shows what was previously entered for Dept/Vendor Responsibility  --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td class="red" id="paddingformultitop">
    Dept/Vendor Responsibility*:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <select name="deptvendor_#count#">
    <option value="" selected>Make A Selection</option>
    <cfloop query="getDeptVendor">
    <option value="#pk_deptVendor#"<cfif #pk_deptVendor# is #dept_responsibility#>selected</cfif>>#pk_deptVendor#</option>
    </cfloop>
    </select>
    </td>
    </tr>
    </table>
     
    <!--- Shows what was previously entered for RMA Data Only  --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td id="paddingformultitop">
    RMA Data Only:&nbsp;&nbsp;&nbsp;&nbsp;
    </td>
    <td class="rmanmoveinmulti">
    ( You may enter up to 1000 characters. )
    <br/>
    <textarea maxlength="1000" onkeyup="return rmaismaxlength(this)" onkeydown="return rmaismaxlength(this)" rows="4" cols="60" name="rma_#count#" >#rma_data#</textarea>
    </td>
    </tr>
    </table>
    <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count#">
    <input type="hidden" name="serialcount" id="serialcount" value="#count#">
    <!--- Adds Delete to every ticket  --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td>
    <input type="button" class="removeticket" value="Remove Serial #count#" onclick="removeElement('dynamic#count#Input')">
    </td>
    </tr>
    <tr>
    <td>
    <input type="button" class="addticket" value="Add Parts" 
    onclick="addpartInput('dynamic#count#Input')">
    </td>
    </tr>
    </table>
    
    
    <!---Shows what was previously entered into parts table--->
    <!---dbtype="query"--->
    <cfquery name="getparts" dbtype="query" >
    SELECT *
    FROM parts
    WHERE fk_serialNo=<cfqueryparam value="#pka_serialNo#" 
    cfsqltype="cf_sql_char" maxLength="20">
    </cfquery>
    <cfset count1 = 0>
    <!---<cfif serial.recordcount is 0>--->
    <cfloop query="getparts">
    <cfset count1 = count1 + 1>
    <div id="part#count1#Name#count1#">
    <!---THIS IS THE PARTS SECTION--->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <th class="sectiontitle" colspan="7">Parts Information #count1# Serial Information #count#</th>
    <tr>
    <td class='indent' id='formfieldpadding'>HC P/N:&nbsp;&nbsp;&nbsp;<input type='text' name="hcpn_#count1#" style="margin:0px" value="#hc_partNo#"></td>
    <td class="red">
    Parts been returned*
    <input type="checkbox" name="partsreturn_#count1#" value="#part_returned#"<cfif #part_returned# eq "1">checked=yes</cfif>/>
    </td>
    <td>
    <td class="indent">Defective<input type="checkbox" name="defective_#count1#" value="#defective#"<cfif #defective# eq "1">checked=yes</cfif>/></td>
    </td>
    </tr>
    </table>
    
    <!--- Adds Delete to every ticket  --->
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td>
    <input type="button" class="removeticket" value="Remove Parts #count1#" 
    onclick="removetheElement('part#count1#Name#count1#')"></a>
    </td>
    </td>
    </tr>
    </table>
    </div>
    </cfloop>
    </div>
    </cfoutput>
    <input type="hidden" value="<cfoutput>#count#</cfoutput>" name="theValue" id="theValue" />
    
    
    <!---If have any blanks in serial table it will make field appear--->
    <cfoutput query="serial">
    <cfset model_no = #model_no#>
    <cfset product_type = #product_type#>
    <cfset type_hardware_failure = #type_hardware_failure#>
    <cfset pka_serialNo = #pka_serialNo#>
    <cfset software_hardware = #software_hardware#>
    <cfset description = #description#>
    <cfset resolution = #resolution#>
    <cfset resolution_date = #resolution_date#>
    <cfset resolution_verified_by = #resolution_verified_by#>
    <cfset verification_date = #verification_date#>
    <cfset dept_responsibility = #dept_responsibility#>
    <cfset rma_data = #rma_data#>
    </cfoutput>
    <cfif serial.recordcount is 0>
    <cfset model_no = "">
    <cfset product_type = "">
    <cfset type_hardware_failure = "">
    <cfset pka_serialNo = "">
    <cfset software_hardware = "">
    <cfset description = "">
    <cfset resolution = "">
    <cfset resolution_date = "">
    <cfset resolution_verified_by = "">
    <cfset verification_date = "">
    <cfset dept_responsibility = "">
    <cfset rma_data = "">
    <cfinclude template="serialdisplay.cfm">
    </cfif>
    <!---
    <cfset count = 0>
    <cfoutput query="parts">
    <cfset count = count + 1>
    <div id="partscount#count#">
    
    <table class="zpExpandedTable" id="resoltable" cellpadding="1" cellspacing="0">
    <tr>
    <td class="indent" id="formfieldpadding">Follow up Date:(MM/DD/YYYY)&nbsp;&nbsp;&nbsp;
    <input type="text" name="followdate_#count#" value="" size="8"/>&nbsp;&nbsp;&nbsp;
    Current Date<input type="checkbox" name="followcheck_#count#" value="" onClick="followdate.value=fill_date()"/></td>
    <td>On Site:</td>
    <td><select name="onsite_#count#">
    <option value="No Choice" selected>No Choice</option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select><td>
    <td># of Onsite:</td><td><select name="numonsite_#count#">
    <option value="" selected>No Choice</option>
    <cfloop from="0" to="10" index="nonsite"><cfoutput>
    <option value="#nonsite#">#nonsite#</option></cfoutput></cfloop>
    </select><td>
    </tr>
    </table>
    <input type="hidden" name="serialcount" value="#count#">
    
    
    
    
    <!--- Parts Information, display parts if have or don't have a value --->
    <cfoutput query="parts">
    <cfset hc_partNo = #hc_partNo#>
    <cfset part_returned = #part_returned#>
    <cfset defective = #defective#>
    <cfinclude template="partsdisplay.cfm">
    </cfoutput>
    <cfif parts.recordcount is 0>
    <cfset hc_partNo = "">
    <cfset part_returned = "">
    <cfset defective = "">
    <cfoutput><cfinclude template="partsdisplay.cfm"></cfoutput>
    </cfif>
    
    ---></div>
         <input type="button" class="addticket" value="Add Serial" onClick="addInput('dynamicInput');" >
    Thank you,
    Rach

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #32
      Where you're setting the ID: "part#count1#Na me#count1#" it should be #count# for one of them. If you remember, it uses the parts count and the serial count.

      Comment

      • bonneylake
        Contributor
        • Aug 2008
        • 769

        #33
        Originally posted by acoder
        Where you're setting the ID: "part#count1#Na me#count1#" it should be #count# for one of them. If you remember, it uses the parts count and the serial count.
        Hey Acoder,

        So this one would be correct right?

        Code:
        <div id="part#count1#Name#count#">
        i looked and compared the insert to the edit. An the only thing different i can see is when you look at dynamic 2 in my insert it does this

        Code:
        <input id="partscount2" type="hidden" value="1" name="partscount2"/>
        <input id="serialcount" type="hidden" value="2" name="serialcount"/>
        and in my edit it does this

        Code:
        <input id="partscount2" type="hidden" value="2" name="partscount2"/>
        <input id="serialcount" type="hidden" value="2" name="serialcount"/>
        also noticed if you look at the first dynamic input and look at the add parts and remove serial it says this

        this is what it looks like for creating

        Code:
        <input class="removeticket" type="button" onclick="removeElement('dynamic1Input')" value="Remove Serial "1""/>
        </td>
        </tr>
        <tr>
        <td>
        <input class="addticket" type="button" onclick="addpartInput('dynamic1Input')" value="Add Parts"/>
        an this is what it looks like in edit

        Code:
        <input class="removeticket" type="button" onclick="removeElement('dynamic1Input')" value="Remove Serial 1"/>
        </td>
        </tr>
        <tr>
        <td>
        <input class="addticket" type="button" onclick="addpartInput('dynamic0Input')" value="Add Parts"/>
        do i need to create another count in the serial section so that adding parts will act right?

        Thank you,
        Rach

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #34
          No, just make sure that #count# is always used for serial counting and #count1# for parts counting.

          Comment

          • bonneylake
            Contributor
            • Aug 2008
            • 769

            #35
            Hey Acoder,


            I figured it out. This line needed to be in the parts div instead of the serial div.

            Code:
            <input type="hidden" name="partscount#count#" id="partscount#count#" value="#count1#">
            but i have now ran into another problem with the inserting. When i was testing it. I accidentally deleted one of the parts an so instead of parts 1 parts 2 parts 3 i had
            parts 1 parts 3 an when i submitted i got the following error

            Error Diagnostic Information

            An error occurred while evaluating the expression:


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


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

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

            is there anyway for it to make it work where if a user deleted one it will still keep going. The serial one was able to work even if i user deleted the 2 out of it.

            Thank you,
            Rach

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #36
              Ah, it seems it's using one count for all parts instead of a separate count for each set of parts in a particular serial. Make sure you have separate counts.

              Comment

              • bonneylake
                Contributor
                • Aug 2008
                • 769

                #37
                Originally posted by acoder
                Ah, it seems it's using one count for all parts instead of a separate count for each set of parts in a particular serial. Make sure you have separate counts.
                Hey Acoder,

                yeah i figured out its problem wanted the hidden parts count in the parts section. an forgot to add the count for serial behind each field (like we did in the parts section of javascript).But now i am having problems with the insert of parts again see above.

                Thank you,
                Rach

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #38
                  Well done. I guess I replied too early ;)

                  As for the new problem, to solve it, you could copy the values from the later parts to the deleted part and above and delete the last one. Do you see how that would work?

                  Comment

                  • bonneylake
                    Contributor
                    • Aug 2008
                    • 769

                    #39
                    Originally posted by acoder
                    Well done. I guess I replied too early ;)

                    As for the new problem, to solve it, you could copy the values from the later parts to the deleted part and above and delete the last one. Do you see how that would work?
                    Hey Acoder,

                    You definately lost me on that one. An the thing is the user might add for example 5 parts an delete 2 and 4 an then it be 1,3,and 5 left. So i don't know if just deleting the last one would work.An i just noticed something else (sigh) but when i didn't add any parts and added 2 serials an clicked submit it brought up the error

                    An error occurred while evaluating the expression:


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


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

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

                    an sadly thats not good either cause sometimes the user might not add any parts. Any ideas?

                    Thank you :),
                    Rach

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #40
                      Let me explain how that would work with an example. If you have five parts and want to delete no.2 and move 3 to 2, 4 to 3 and 5 to 4 then delete the last one, all the parts will be intact and no. 2 will be removed. That may seem a lot of work, but with a loop it's not as much as you think.

                      That's one option. Another option is to store the numbers of the parts and delete part numbers from that field. You can use the field value in place of a count because it would be a list and you can use listlen to get the count. This would probably be the easier solution.

                      Comment

                      • bonneylake
                        Contributor
                        • Aug 2008
                        • 769

                        #41
                        Originally posted by acoder
                        Let me explain how that would work with an example. If you have five parts and want to delete no.2 and move 3 to 2, 4 to 3 and 5 to 4 then delete the last one, all the parts will be intact and no. 2 will be removed. That may seem a lot of work, but with a loop it's not as much as you think.

                        That's one option. Another option is to store the numbers of the parts and delete part numbers from that field. You can use the field value in place of a count because it would be a list and you can use listlen to get the count. This would probably be the easier solution.
                        Hey Acoder,

                        Well whatever way you think would be the best way. The only thing with the first suggestion i am worried about is this. What if they delete 2 fields. Instead of just no 2, lets say we have 5 total fields an we delete 2 and 4 then would all the remaining fields become 1, 2 and 3 or would it remain like 1,2,3,5? mostly what i am worried about is them deleting more then one field. But whatever way you think would be best then lets start with that.

                        Thank you :),
                        Rach

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #42
                          That shouldn't be a problem because only one part would be deleted at a time.

                          I think, however, that the second solution may make more sense here (even though it would involve changing some of the code that does the inserting). The advantage of the first approach is that you only need to change in one place. The second method seems easier though.

                          Is it necessary that part numbers should go from 1 to, say, 3 instead of having gaps?

                          Comment

                          • bonneylake
                            Contributor
                            • Aug 2008
                            • 769

                            #43
                            Originally posted by acoder
                            That shouldn't be a problem because only one part would be deleted at a time.

                            I think, however, that the second solution may make more sense here (even though it would involve changing some of the code that does the inserting). The advantage of the first approach is that you only need to change in one place. The second method seems easier though.

                            Is it necessary that part numbers should go from 1 to, say, 3 instead of having gaps?
                            Hey Acoder,

                            Well the thing is if it has gaps, is when it runs into problems. When i inserted parts 1, and parts 3. It was going we can't find 2 and can not insert into the database.It basically has a fit when its missing a number.

                            I also i got another problem i wanted to ask on. I ran into the problem where i didn't select any parts at all to upload and got the same error i got for not upload the parts in order saying

                            Code:
                            An error occurred while evaluating the expression: 
                            
                            
                             hcpn            = Form["hcpn_" & ps & "_#machinecount#"]
                            
                            
                            Error near line 96, column 8.
                            --------------------------------------------------------------------------------
                            
                            The member "HCPN_1_1" in dimension 1 of object "Form" cannot be found. Please, modify the member name
                            is there a way to make it not insert a part if a part was not selected?

                            Thank you,
                            Rach

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #44
                              I understand that, but I meant gaps in the numbering for display, e.g. would it be a problem to have part 1 displayed, then part 3 when adding/deleting parts? Of course, this would be academic when you get round to displaying later which will be sorted out.

                              For no parts, you can validate based on the count.

                              Comment

                              • bonneylake
                                Contributor
                                • Aug 2008
                                • 769

                                #45
                                Originally posted by acoder
                                I understand that, but I meant gaps in the numbering for display, e.g. would it be a problem to have part 1 displayed, then part 3 when adding/deleting parts? Of course, this would be academic when you get round to displaying later which will be sorted out.

                                For no parts, you can validate based on the count.
                                Hey Acoder,

                                Based on what i know i don't think it would be a problem as long as it wouldn't affect how it displayed back later Because how it displays back doesn't have to be parts 1, parts 3. It can just be parts 1 parts 2. But how would i validate the count?

                                Thank you,
                                Rach

                                Comment

                                Working...