Duplicate Field

This code will allow you to make a text box on your form that automatically duplicates it's input into a second field. For this example, UMstreet is being copied into UMbillstreet. This allows you to use the billing street address to check the AVS result without having to request the billing address twice.

This method can be used for any textbox you would like to use for more than one field. Use the examples below as a template.

Javascript

Locate this section:

<script type="text/javascript">
     var submitted = false;
     function submitform()
     {
       if(submitted) {
         return false;
       }
       submitted=true;
       document.epayform.submitbutton.value='Please Wait... Processing';
       return true;
     }
</script>

Insert a new line directly below and add the following code Please Note: Replace UMstreet with the field you would like to duplicate. Replace UMbillstreet with the field where you would like the original field contents duplicated.:

<script type="text/javascript">
  function copyField()
  {
    var form = document.epayform;
    form.UMbillstreet.value=form.UMstreet.value;
    form.UMbillzip.value=form.UMzip.value;
  }
</script>

HTML

Next, find the hidden input fields. It should look like this:

<input type="hidden" name="UMcommand" value="[UMcommand]">
<input type="hidden" name="UMamount" value="[UMamount]">
<input type="hidden" name="UMtax" value="[UMtax]">
<input type="hidden" name="UMinvoice" value="[UMinvoice]">
<input type="hidden" name="UMcustid" value="[UMcustid]">
<input type="hidden" name="UMrecurring" value="[UMrecurring]">

Add a line below for the field where you are duplicating the original field. Our example is below:

<input type="hidden" name="UMbillstreet" value="">

If the field where you are duplicating the original field is currently visible on the form, DELETE IT. The line for UMbillstreet looks like this:

<div class="form-group">
  <span class="col-form-label col-sm-4 col-xs-12 ">Address</span>
  <div class="col-md-8 col-xs-12 ">
    <input id="UMbillstreet" name="UMbillstreet" class="form-control" type="text" placeholder="Address" value="[UMbillstreet]">
  </div>
</div>

Lastly, find the input tag for the field you are duplicating:

<div class="form-group">
  <span class="col-form-label col-sm-4 col-xs-12 ">Card Billing Address</span>
  <div class="col-md-8 col-xs-12 ">
    <input id="UMstreet" name="UMstreet" class="form-control" type="text" placeholder="Card Billing Address" value="[UMstreet]">
  </div>
</div>

Add onChange="copyField()" to the input tag so it looks like this:

<div class="form-group">
  <span class="col-form-label col-sm-4 col-xs-12 ">Card Billing Address</span>
  <div class="col-md-8 col-xs-12 ">
    <input id="UMstreet" name="UMstreet" class="form-control" type="text" placeholder="Card Billing Address" value="[UMstreet]" onChange="copyField()">
  </div>
</div>

Once you have saved changes to your payment form, one text box will populate into two fields.