Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Dynamic input field generation

    Hi all,

    I have a complicated (well to me it is!) problem with a form I am creating for my site. The form has three sections with the ability to add another field unlimited times. There is one for adding ingredients, one for equipment and one for steps

    The name and id does increment on all 3 however the problem is they seem to all be using the same count, by this I mean that if I add 2 steps (which brings the count to 3) and then add an ingredient, the ingredient id goes to ingredient4 - obviously because it is taking the count that step has set. I am no javascript guru, I am more a designer so I'm really struggling, Ive been working on this one for days..

    There is also another problem in that if I create say 3 steps bringing the count up to step4 and then remove the second step, I cant see how I can bring the other steps after step2 count down by one, at the moment step4 and step3 are staying as step3 and step4 but because step2 was removed they should drop down to becoming step2 and step3. My php that inserts the data into my db isnt working because the ids keep getting messed up

    I have a demo URL up on ajburchell.com/form.html

    If anyone can help me with this I will be extremely grateful

    Thank you in advance

  2. #2
    Senior Coder
    Join Date
    Dec 2010
    Thanked 570 Times in 563 Posts
    First of all: Never ever use more than one instance of jQuery on the same page. You are using versions 1.3.2 and 1.6.4 together, which will create problems.

    Second: You use the global "var current" several times. Each one overwrites the previous one in that case.

    Despite this, when I add two new Ingredient areas and fill out number 3 for example, I can see from the POST request that it was correctly sent as ingredient3. So I don't see the problem


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts