displaying previously entered multiple fields

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

    #61
    Originally posted by acoder
    It should go next to the partscount input field in the addInput() function.
    Hey Acoder,

    So something like this correct?

    Code:
    "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
    "<input type="hidden" name="parts1list1" id="parts1list1" value="">" +
    "<input type='hidden' name='serialcount' id='serialcount' value='" + count + "'>";
     
    <!--- Adds Delete to every ticket  --->
    newdiv.innerHTML = newdiv.innerHTML +
    Thank you,
    Rach

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #62
      Of course, "parts1list 1" was only an example. It needs to be a variable constructed similar to partc.

      Comment

      • bonneylake
        Contributor
        • Aug 2008
        • 769

        #63
        Originally posted by acoder
        Of course, "parts1list 1" was only an example. It needs to be a variable constructed similar to partc.
        Hey Acoder,

        Ok so i added this in the function addinput

        Code:
        var partc = 'partscount'+count;
        var part2c = 'part2count'+count;
        an then here is the 2 hidden fields
        Code:
        "<input type='hidden' name='"+partc+"' id='"+partc+"' value='0'>" +
        "<input type="hidden" name='"+part2c+"' id='"+part2c+"' value="">" +
        Is this correct?

        Thank you,
        Rach

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #64
          That's one thing done. Then in addInput, you need to update this field with the count number plus a comma. In the delete function, remove the part number being deleted.

          Comment

          • bonneylake
            Contributor
            • Aug 2008
            • 769

            #65
            Originally posted by acoder
            That's one thing done. Then in addInput, you need to update this field with the count number plus a comma. In the delete function, remove the part number being deleted.
            Hey Acoder,

            How would i go about updateing it? something like

            Code:
            part update = 'part2count'+count';
            an then for delete, would i delete it like so from the addinput function?

            Code:
            <!---Allows us to remove multiple fields --->
            function removeElement(divNum) {
              var d = document.getElementById('dynamicInput');
              var olddiv = document.getElementById(divNum);
              d.removeChild.part2c(olddiv);
            }
            Thank you,
            Rach

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #66
              Although this is now JavaScript, since it links with the Coldfusion, we can leave it in this thread.

              For the adding, look how you update the parts count. Do something similar with this new field with the difference being that instead of setting the count value, you append it using +=

              Comment

              • bonneylake
                Contributor
                • Aug 2008
                • 769

                #67
                Originally posted by acoder
                Although this is now JavaScript, since it links with the Coldfusion, we can leave it in this thread.

                For the adding, look how you update the parts count. Do something similar with this new field with the difference being that instead of setting the count value, you append it using +=
                Hey Acoder,

                Confused by, are you meaning something like

                Code:
                var partupdate = 'part2count'+=count';
                or maybe

                Code:
                var partupdate = 'part2count'+count+=';
                Thank you,
                Rach

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #68
                  Sorry, I meant in addpartInput(), you have something like:
                  Code:
                  var serialno = partName.replace("dynamic","").replace("Input","");
                  var avalue = document.getElementById("partscount"+serialno);
                  var count = parseInt(avalue.value) + 1;
                  avalue.value = count;
                  so you'd use something similar for parts2count except that instead of avalue.value = count, you'd set partslist.value += count + ",".

                  Comment

                  • bonneylake
                    Contributor
                    • Aug 2008
                    • 769

                    #69
                    Originally posted by acoder
                    Sorry, I meant in addpartInput(), you have something like:
                    Code:
                    var serialno = partName.replace("dynamic","").replace("Input","");
                    var avalue = document.getElementById("partscount"+serialno);
                    var count = parseInt(avalue.value) + 1;
                    avalue.value = count;
                    so you'd use something similar for parts2count except that instead of avalue.value = count, you'd set partslist.value += count + ",".
                    Hey Acoder,

                    I added this to addpartInput. does it need to be partslist or does it need to part2c?

                    Code:
                    var count = parseInt(avalue.value) + 1;
                    avalue.value = count;
                    partslist.value += count + ",";
                    Thank you,
                    Rach

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #70
                      partslist was just a variable name that I made up. You'll need to set it to the element in question first before setting its value:
                      Code:
                      var partslist = document.getElementById("parts2count"+serialno);

                      Comment

                      • bonneylake
                        Contributor
                        • Aug 2008
                        • 769

                        #71
                        Originally posted by acoder
                        partslist was just a variable name that I made up. You'll need to set it to the element in question first before setting its value:
                        Code:
                        var partslist = document.getElementById("parts2count"+serialno);
                        Hey Acoder,

                        So something like this correct?

                        Code:
                        avalue.value = count;
                        var partslist = document.getElementById("parts2count"+serialno);
                        partslist.value += count + ",";
                        Thank you,
                        Rach

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #72
                          That's one part done. Now you need to add some lines in the delete function to remove the part number being deleted. You'll need the serial number again, so you can copy that line. The input field value is a string, so you can use replace() like how you set the serialno variable.

                          Comment

                          • bonneylake
                            Contributor
                            • Aug 2008
                            • 769

                            #73
                            Originally posted by acoder
                            That's one part done. Now you need to add some lines in the delete function to remove the part number being deleted. You'll need the serial number again, so you can copy that line. The input field value is a string, so you can use replace() like how you set the serialno variable.
                            Hey Acoder,

                            Not sure if i copied the 2 correct lines, but here is what i have. I added it to the delete function in the parts function

                            Code:
                            <!---Allows us to remove multiple fields--->
                            function removetheElement(divNum) {
                              var d = document.getElementById('partsInput');
                              var partslist = document.getElementById("parts2count"+serialno);
                              var serialno = partName.replace("dynamic","").replace("Input","");
                              var olddiv = document.getElementById(divNum);
                             olddiv.parentNode.removeChild(olddiv);
                            }
                            Thank you,
                            Rach

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #74
                              divNum which is passed into this function is partIdName set in the addpartInput function. partIdName is set like this:
                              Code:
                              var partIdName = 'part' + count + 'Name' + serialno;
                              so you need to do some string manipulation (see methods) to get the count and serial number values.

                              Comment

                              • bonneylake
                                Contributor
                                • Aug 2008
                                • 769

                                #75
                                Originally posted by acoder
                                divNum which is passed into this function is partIdName set in the addpartInput function. partIdName is set like this:
                                Code:
                                var partIdName = 'part' + count + 'Name' + serialno;
                                so you need to do some string manipulation (see methods) to get the count and serial number values.
                                Hey Acoder,

                                Ok are you saying the 2 strings i added where incorrect an i need to add the line you have above? an then what type of string manipulation do i need to do to it? something like

                                Code:
                                var replace = partIDName.replace("part","count").replace("Name","serialno");
                                Thank you,
                                Rach

                                Comment

                                Working...