#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    9
    Rep Power
    0

    I really need to be pointed in the right direction


    I am building a script for receipts. What I need to do is set up 3 text boxes for the ingredient, the amount, and measure amount.
    Not knowing how many ingredients will be called for I need to be able to click on a next ingredient button and have a new row of test boxes show on the page. This will need to happen for each ingredient. I will then save it to an array in a db.

    Can anyone give me some advice please.

    Snickers123
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    677
    Rep Power
    7
    I'd maybe use some javascript for the adding of the ingredient boxes, incrmenting their name something like ingred1, ingred2, ingred3, and on your proccess page run perhaps an if/then to check if each added box exists. *shrugz*
  4. #3
  5. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,126
    Rep Power
    9398
    Either
    a) Name the textboxes like "ingredient[]", "amount[]", and "measure[]". Then $_POST["ingredient"] and all will be arrays, not just single strings. Loop over them.
    b) Name the textboxes like "ingredient[123][name]", "ingredient[123][amount]", and "ingredient[123][measure]". Then $_POST["ingredient"] will be an array, and each of those will be arrays with the name, amount, and measure. The 123 can come from anywhere but it has to be unique for each row.
  6. #4
  7. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    definitely with javascript for the most convenient way.

IMN logo majestic logo threadwatch logo seochat tools logo