Make my Billing and Shipping Fields Match

Posted by user1899209 on Stack Overflow See other posts from Stack Overflow or by user1899209
Published on 2012-12-12T21:46:09Z Indexed on 2012/12/12 23:03 UTC
Read the original article Hit count: 179

Filed under:

I want to make my Billing fields automatically match my Shipping fields. I can make it work with text values, but I can't automatically populate a RADIO BUTTON. I'm using this code: http://jsfiddle.net/aDNH7/ I would like to keep this in Javascript.

<script>
function FillBilling(f) {
  if(f.billingtoo.checked == true) {
    f.billingname.value = f.shippingname.value;
    f.billingcity.value = f.shippingcity.value;
  }
    if(f.billingtoo.checked == false) {
    f.billingname.value = '';
    f.billingcity.value = '';
  }
}
</script>
<td bgcolor="eeeeee">
<b>Mailing Address</b>
<br><br>
<form>
Name:
<input type="text" name="shippingname">
<br>
City:
<input type="text" name="shippingcity">


/> Checking
/> Savings

<br>
<input type="checkbox" onclick="FillBilling(this.form)" name="billingtoo">
<em>Check this box if Billing Address and Mailing Address are the same.</em>
<p>
<b>Billing Address</b>
<br><br>
Name:
<input type="text" name="billingname">
<br>
City:
<input type="text" name="billingcity">


/> Checking
/> Savings

?

BUT, I want to add this to the form:

<!-- <td colspan="2"><p>
  <label>
    <input type="radio" name="acct" value="checking" id="acct_0" <?php if ($user_info['acct'] == "checking"){ echo "checked='checked'"; }?>/>
    Checking</label>
  <br />
  <label>
    <input type="radio" name="acct" value="savings" id="acct_1" <?php if ($user_info['acct'] == "savings"){ echo "checked='checked'"; }?>/>
    Savings</label>
  <br />
</p>
</td>-->

© Stack Overflow or respective owner

Related posts about JavaScript