Funky Remove

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Csanád
    New Member
    • Jul 2007
    • 17

    Funky Remove

    Hi,

    Here's my form - it's still work in progress, but I got stuck with the Remove Item option.



    Here's my dilemma:

    As long as I don't remove the very first Item, everything works as expected, i.e. I can add Dependant Items. But if I remove the first Item and add a Another Item, then the "Add a Dependant Item" button will not work.

    Any ideas?

    Thank you!

    Csanád
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Csanád.

    Works great in Safari!

    Instead of trying to dynamically create all those nodes, try cloning a template:

    [code=html]
    <div id="dolly" style="display: none;">
    .
    .
    .
    </div>
    [/code]

    [code=javascript]
    function createNode($i)
    {
    var $newNode = document.getEle mentById('dolly ').cloneNode(tr ue);
    $newNode.id = 'Element_' + $i;
    $newNode.style. display = '';

    document.forms[0].appendChild($n ewNode);
    }
    [/code]
    You can clone and remove to your heart's content, and as long as your 'dolly' (get it?) is originally coded outside the main form, it will not be submitted with the form.

    Comment

    • Csanád
      New Member
      • Jul 2007
      • 17

      #3
      Funky Remove - Take 2

      Hello again :)

      Here's my form:

      http://www.steinrogan. com/SecureSite_v2_b eta/new_category.ht ml

      Please do the following:

      1. Add about 9 more New Items by clicking on the Add Another Item.

      2. Go back to Item[1] and start removing the Item[1]. (Renumbering the following Items in the list is being done automatically, so for example, if you remove Item[2] from a list that has 4 Items, Item[3] and Item[4] will become Item[2] and Item[3], respectively.) Keep removing Item[1] and observe how the space between Category Name and Item[1] gets bigger.

      3. Try to find and answer and please let me know. :)

      Thank you!

      Csanád

      Comment

      • Csanád
        New Member
        • Jul 2007
        • 17

        #4
        Heya Pbmods,

        For some reason cloning does not work for me. God knows I tried! After 3-4 hours of pain, I gave up and went with creating the nodes dynamically.

        Everything works except for one thing. I posted a new thread in case you're interested. Subject: "Funky Remove - Take 2."

        Thanks for your help!

        Csanád

        Comment

        • Csanád
          New Member
          • Jul 2007
          • 17

          #5
          Found it! :)

          There was an extra <br> sibling hangin' there after removing its previous sibling, i.e. the Item that was being removed.

          Cheers!

          Csanád

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Csanád.

            Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Heya, Csanád.

              Were you able to fix the remove problem then?

              Comment

              • Csanád
                New Member
                • Jul 2007
                • 17

                #8
                Heya Pbmods,

                Yes. I fixed it. Thanks for asking though!

                Cheers,

                Csanád

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  Heya, Csanád.

                  Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

                  Comment

                  Working...