severndigital Posted May 30, 2007 Share Posted May 30, 2007 does anyone know of a good in-depth tutorial on how to do this?? basically copying billing information fields to shipping information fields. i can only find completed scripts and i was looking to learn how to and more importantly what is happening when i script this. instead of just copy/pasting code. thanks in advance, chris Quote Link to comment Share on other sites More sharing options...
nogray Posted May 30, 2007 Share Posted May 30, 2007 Here is an easy way to do it without too much work, let's say you have address_line1, address_line2, city, state, zip So you'll have the shipping and billing address something similar to this (I use id to make it easier) .... <input type="text" name="address_line1_shipping" id="address_line1_shipping" .... <input type="text" name="address_line1_billing" id="address_line1_billing" ..... Now, you need a checkbox, button, or a link that will have an onclick event to call the function that will copy the data. <a href="#" onclick="fill_shipping(); return false;">Copy Address</a> Your javascript function will take the information from the billing and put in the shipping fields, for the state select menu, you can use the selectedIndex to change the selection function fill_shipping(){ document.getElementById('address_line1_shipping').value = document.getElementById('address_line1_billing').value; ... document.getElementById('state_shipping').selectedIndex = document.getElementById('state_billing').selectedIndex; ... } This is the general idea, hope this helps. Quote Link to comment Share on other sites More sharing options...
lighton Posted June 9, 2007 Share Posted June 9, 2007 would you also happen to know how one go about doing this between two <select multiple="multiple"> lists since it would require appending values and keys???? e.g. <option name="key">value</option> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.