You need to give visitors to your site an easy way to enter the same information twice.
Use an onClick event handler in a form input, such as a checkbox:
<input type="checkbox" name="billingasshipping" value="1" onclick="BillingAsShipping(this.form);">
Figure 7-2 shows an example of a form that puts this feature into action.
The BillingAsShipping function takes one argument: the name of the form to process. Since the form in this example does not have a value in its name attribute, the shorthand this.form works. If you assign names to your forms, you may need to tweak the code to get it to work.
In this Recipe, I've distinguished the billing fields from the shipping fields by prepending a "b" or "s" to their namessuch as blname and slname for the last names on each address on the order form.
When the visitor clicks the checkbox, the function replaces the values of all the shipping fields (starting with "s") with the values of analogous fields starting with "b" (the billing fields).