[x show="line1"](https://formidableforms.com/knowledgebase/address/#kb-display-address-fields) But is there any way to dynamically populate hidden fields with each of the elements individually? I am experimenting with a JavaScript solution now but not having much luck. Thanks!
<script type="text/javascript">
   var restaurantStreet = document.getElementById('field_tjadd_line1').value;
   var restaurantSuite = document.getElementById('field_tjadd_line2').value;
   var restaurantCity = document.getElementById('field_tjadd_city').value;
   var restaurantState = document.getElementById('field_tjadd_state').value;
   var restaurantZip = document.getElementById('field_tjadd_zip').value;
   document.getElementById('field_tjadd_line1').addEventListener('change', function() {
       doChange();
   });
   document.getElementById('field_tjadd_line2').addEventListener('change', function() {
       doChange();
   });
   document.getElementById('field_tjadd_city').addEventListener('change', function() {
       doChange();
   });
   document.getElementById('field_tjadd_state').addEventListener('change', function() {
       doChange();
   });
   document.getElementById('field_tjadd_zip').addEventListener('change', function() {
       doChange();
   });
   //ONE FUNCTION TO RULE THEM ALL
   function doChange() {
       restaurantStreet = document.getElementById('field_tjadd_line1').value;
       document.getElementById("field_rf041").value = restaurantStreet;
       restaurantSuite = document.getElementById('field_tjadd_line2').value;
       document.getElementById("field_rf041").value = restaurantStreet + ' ' + restaurantSuite;
       restaurantCity = document.getElementById('field_tjadd_city').value;
       document.getElementById("field_2n1uj").value = restaurantCity;
       restaurantState = document.getElementById('field_tjadd_state').value;
       document.getElementById("field_5g8u").value = restaurantState;
       restaurantZip = document.getElementById('field_tjadd_zip').value;
       document.getElementById("field_symjs").value = restaurantZip;
   }
</script>
Thanks for sharing!
That's beautiful. Wonderfully generous share, as well. Thanks!
Please login or Register to submit your answer
If you're going to populate hidden (individual) fields anyway, wouldn't it be easier to just use those fields instead of the "adress" field in Formidable? Also
However thanks for the javascript. Might be usefull sometime 🙂
@Wilco Wietsma - I can't use the address Geolocation on regular fields unfortunately. That would've been much easier, for sure!
What do you mean by that Amy? I was using the Google Maps API on regular fields long before there was a Geolocation add-on. Personally, I have never "played" with Geo add-on, but I doubt I would use it on one of my personal projects. I find it easier just to write the code myself than to learn another tool.
@Victor Font - I have a couple goals in mind with this client-driven project:
1 - On the front end of the site for users, I want them to be able to enter part of their address and then be able to use the Geo Add-On to dynamically populate the other parts of ther address. It's a much nicer experience than using several individual fields to collect pieces of an address.
2 - On the back end of the site for admins, I needed to be able to pull out just the street address, just the ZIP code, etc. in order to accurately sync parts of the address to various Salesforce fields. This is another reason why I needed to use the multi-field group of "Address" instead of the single line Address field.
So I did mis-type early: the Geo Add-On may work on "regular" fields but so far I haven't figured out how to group them to all dynamically populate together.
If I wasn't using Formidable or a third-party plugin, I would for sure write my own code - but in favor of efficiency and reducing possible errors, I look to Formidable and its Add Ons to do the heavy lifting.