Greetings experts,
We have a form that collects information from the user.
Such information as name, phone, email, street address, etc
On the form, when a user is asked to provide his/her shipping address, there is a checkbox that asks the user to check that box if shipping address s/he is providing is same as mailing address.
If the user says yes, then the shipping address is copied over to mailing address.
I use JS to do this and it works just fine.
On the DB side, I have the following:
If your business requirements do not call for it, you don't have to create a table for storing addresses. But there may be some good reasons to do so even if that is not a current requirement. Think through the various scenarios you may need to support, such as how you will support it if
the user changes their address, or
if they want to have two or more shipping addresses, or
if you are asked to keep history of their addresses and/or shipping addresses
If you login on Amazon.com, and see the options they give you, you can get an idea of the kind of things you will need to support. But
In the scenario you are describing, you can do without a field/column in the database to represent whether shipping address is the same as the mailing address. Your workflow would be something like this:
You always have shipping and mailing address, along with the checkbox in your user interface.
If the user checks the box, then you disable and auto-populate the shipping address to be the same as the mailing address.
When you save the data into the database, you always save the shipping and mailing address, regardless of whether they are the same or not