title: Copy address fields into billing address fields
body: <p>I want to copy the user's address into the billing address fields based on a checkbox value. But every time when the checkbox is checked only the last value of the input fields gets copied to the billing address section. And it is important not to use the ids because they are dynamically set.</p>
  
  <p>Javascript:</p>
  
  <pre><code>$(function () {
      var checkbox = $('#veranstaltungsanmeldung_billing_address'); 
  
      checkbox.on('click', function(){
          if(checkbox.prop('checked')) {
              var srcValues = [];
  
              $(".address").each(function(){
                  var srcValue = $(this).find('input[data-src]').val();
                  srcValues.push(srcValue);
              });
  
              $.each(srcValues, function(index){
                  $('.billing-address').find('input[data-dst]').val(srcValues[index]);
              });
          }
      });
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action="{{ path('veranstaltungsanmeldungsubmit') }}/{{ danksagungsid }}" method="post"  id="veranstaltungsanmeldung" class="form-horizontal" role="form"  enctype="multipart/form-data"&gt;
  {% if validationErrors is defined %}
      &lt;div class="form-error"&gt;
          {{ validationErrors }}
      &lt;/div&gt;
  {% endif %}
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.anrede.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.anrede"|trans }}:{% if form.vorname.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.anrede, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.titel.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.titel"|trans }}:{% if form.titel.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.titel, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.vorname.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.vorname"|trans }}:{% if form.vorname.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.vorname, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.nachname.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.nachname"|trans }}:{% if form.nachname.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.nachname, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group address"&gt;
      &lt;label for="{{ form.unternehmen.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.unternehmen"|trans }}:{% if form.unternehmen.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.unternehmen, {
              'attr': { 'class': 'form-control', 'data-src': 'company' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.funktion.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.funktion"|trans }}:{% if form.funktion.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.funktion, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group address"&gt;
      &lt;label for="{{ form.strasse.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.strasse"|trans }}:{% if form.strasse.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.strasse, {
              'attr': { 'class': 'form-control', 'data-src': 'street' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.postleitzahl.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.plz"|trans }}:{% if form.postleitzahl.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-3"&gt;
          {{ form_widget(form.postleitzahl, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
      &lt;label for="{{ form.ort.vars.id }}" class="col-sm-2 col-lg-1 control-label"&gt;{{ "form.ort"|trans }}:{% if form.ort.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-5 col-lg-6"&gt;
          {{ form_widget(form.ort, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.land.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.land"|trans }}:{% if form.land.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.land, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.telefon.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.telefon"|trans }}:{% if form.telefon.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.telefon, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="{{ form.e_mail.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.e_mail"|trans }}:{% if form.e_mail.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.e_mail, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  
  {% if location.id != 3481794 %}
      &lt;div class="form-group"&gt;
          &lt;label for="{{ form.anmerkungen.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.anmerkungen"|trans }}:{% if form.anmerkungen.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
              {{ form_widget(form.anmerkungen, {
                  'attr': { 'class': 'form-control' }
              })}}
          &lt;/div&gt;
      &lt;/div&gt;
  {% endif %}
  
  &lt;div class="form-group"{% if not ez_field_value(content, 'show_billing_fields').bool or (location.id != 3486083 and location.id != 3486084) %} style="display: none;"{% endif %}&gt;
      &lt;label for="{{ form.billing_occupation.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.careercenter.billing_occupation.label"|trans }}:{% if form.billing_occupation.vars.required == true %} *{% endif %}&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          {{ form_widget(form.billing_occupation, {
              'attr': { 'class': 'form-control' }
          })}}
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group hide-legend"&gt;
      &lt;label for="{{ form.freies_attribut.vars.id }}" class="col-sm-2 control-label"&gt;
          {{ form.freies_attribut.vars.label }}
      &lt;/label&gt;
      &lt;div class="col-sm-10 select-list"&gt;
          &lt;fieldset&gt;
              &lt;legend&gt;{{ form.freies_attribut.vars.label }}&lt;/legend&gt;
              {{ form_widget(form.freies_attribut) }}
          &lt;/fieldset&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="checkbox billing-address-checkbox"{% if not ez_field_value(content, 'show_billing_fields').bool %} style="display: none;"{% endif %}&gt;
      &lt;label&gt;
          {{ form_widget(form.billing_address) }} {{ "form.billing_address"|trans }}{% if form.billing_address.vars.required == true %} *{% endif %}
      &lt;/label&gt;
  &lt;/div&gt;
  
  {% if location.id == 3481794 %}
      &lt;div class="form-group"&gt;
          &lt;label for="{{ form.anmerkungen.vars.id }}" class="col-sm-12 control-label"&gt;{{ "form.fbd_question"|trans }}:{% if form.anmerkungen.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-12"&gt;
              {{ form_widget(form.anmerkungen, {
                  'attr': { 'class': 'form-control' }
              })}}
          &lt;/div&gt;
      &lt;/div&gt;
  {% endif %}
  
  &lt;div class="event-billing-block"{% if not ez_field_value(content, 'show_billing_fields').bool %} style="display: none;"{% endif %}&gt;
      &lt;h4 class="mt20"&gt;Rechnungsadresse&lt;/h4&gt;
      &lt;div class="form-group billing-address"&gt;
          &lt;label for="{{ form.billing_company.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.unternehmen"|trans }}:{% if form.billing_company.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
              {{ form_widget(form.billing_company, {
                  'attr': { 'class': 'form-control', 'data-dst': 'company' }
              })}}
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group billing-address"&gt;
          &lt;label for="{{ form.billing_street.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.street"|trans }}:{% if form.billing_street.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
              {{ form_widget(form.billing_street, {
                  'attr': { 'class': 'form-control', 'data-dst': 'street' }
              })}}
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="{{ form.billing_zip.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.zip"|trans }}:{% if form.billing_zip.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-3"&gt;
              {{ form_widget(form.billing_zip, {
                  'attr': { 'class': 'form-control' }
              })}}
          &lt;/div&gt;
          &lt;label for="{{ form.billing_place.vars.id }}" class="col-sm-2 col-lg-1 control-label"&gt;{{ "form.place"|trans }}:{% if form.billing_place.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-5 col-lg-6"&gt;
              {{ form_widget(form.billing_place, {
                  'attr': { 'class': 'form-control' }
              })}}
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="{{ form.billing_country.vars.id }}" class="col-sm-2 control-label"&gt;{{ "form.country"|trans }}:{% if form.billing_country.vars.required == true %} *{% endif %}&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
              {{ form_widget(form.billing_country, {
                  'attr': { 'class': 'form-control' }
              })}}
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Would be nice if somebody can help me with this problem.</p>