So I have a website which there are about 10 to 20 forms that need to be filled out throughout the page, however in the middle there is a section which asks if you want to buy something. How I wanted this set up was you could just click “buy” (a button set up to set a variable in an array) and continue on filling in your info. However it occurred to me that if I did that the page would reload with you attempted to press “buy”, effectively clearing all of those fields you just spent time putting information into. Is there some way I can have a “buy” button that sends the sku of the item to an array without reloading the page?
Share
The easiest way to do this is to have a hidden input field that will contain whether or not the user is buying this item. The value is updated when the button is clicked.
However, I might suggest a checkbox instead. Perhaps the user will decide that they don’t actually want to buy this item after they click the button. Having a checkbox allows the user to change their mind.