AnsweredAssumed Answered

Auto-populate form fields based on data in other fields when a checkbox is selected

Question asked by slothman16 on Jul 11, 2017
Latest reply on Jul 20, 2017 by slothman16



The functionality I am trying to replicate is similar to when you have the option to select "same as billing address" when ordering something online to use as the shipping address


I have found this article but I am not familiar with javascript, however there is some confusion about the name of the fields used in the screen shots and the names in the script. Below are my screenshots of the fields and controls involved and the script I am using. I am trying to test with the ShipToAddress and Ctiy to be copied to BillToAddress and City when check box is ticked.






NWF$('#' + Same).click(function(){
  var checkBox = NWF$('#' + varSame);
  if (':checked') == true){
  var ShipToAddress = NWF$('#' + varShipToAddress).val();
  var ShipToCity = NWF$('#' + varShipToCity).val();
  NWF$('#' + varBillToAddress).val(ShipToAddress);
  NWF$('#' + varBillToCity).val(ShipToCity);
  var nullValue = '';
  NWF$('#' + varBillToAddress).val(nullValue);
  NWF$('#' + varBillToCity).val(nullValue);