Jump to content

How to allow users to specify the amount of items on my form?


echeats

Recommended Posts

I have an order form which had 5 part that repeated themselves to allow a person to order up to 5 different items. I originally did it by having $item1, $quantity1, $type1, $item2, $quantity2...etc hardcoded into both the PHP processor and the HTML form (e.g. values of form elements were item1, quantity1, etc).

 

I have now re-coded it so it uses arrays for both the HTML form (the parts that repeat are in the array) and the PHP processor, and all is working fine. Both currently use a variable $itemamount = 5 which is hardcoded into the script.

 

The only thing is, now i have my arrays i was wondering if i can make it so users can somehow input/specify how many items they wish to add? Ideally i don't want to use POST as the form using the arrays has an "if POST" thing that it could mess up. The other slightly problem is that the page is included in a larger CMS type system which means using GET is impossible as you can't get the value into the URL (e.g. by using form.php?itemamount=3)...so i wondered if theres another way of doing this?

 

Basically i either want a seperate page that asks the user how many items he/she wants to order, which then forwards them onto form.php that will give them the form to fill in. Alternatively, if all the code was on the form page and they (by default) have 1 item field and could then somehow click "Add Item..." if they wished to add more and more as many times as they want?

 

So, any ideas? I'm a little stuck so appreciate any help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.