0

I am trying to have billing address populate in the shipping address if its same. does apex has anything native that does this for you? or should I search for jquery Auto populate functions?

  • You could do it via the controller but quicker and easier to just use jQuery – Eric Sep 25 '15 at 22:44
  • alright, Ill search and see if I can find jquery , thank you @Eric – Metawaa Sep 25 '15 at 22:45
  • Depending on your requirement, you could also use a workflow to do this if a box is checked. – smckitrick Sep 26 '15 at 3:24
1

As Eric said you can do it easily with jQuery as below. This example assumes that you have a checkbox to let users allow autofill. Hope this will be a good starting point.

<script type="text/javascript">
$(document).ready(function(){ 
    $('#check-address').click(function(){
        if($('#check-address').attr('checked')){
            $('#address-field1').val($('#address-field').val());
            $('#city-field1').val($('#city-field').val());
            $('#zip-field1').val($('#zip-field').val());
            var state = $('#state-field option:selected').val();
            $('#state-field1 option[value=' + state + ']').attr('selected','selected');
        } else { 
            //Clear on uncheck
            $('#address-field1').val("");
            $('#city-field1').val("");
            $('#zip-field1').val("");
            $('#state-field1 option[value=Nothing]').attr('selected','selected');
        };

    });
});
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.