iFrame Submit Button GA Event Tracker

[email protected]

by Ryan Brackett

HTML

Dynamically add options to JotForm
<br/>
<br/>
<div class="form">
  <script type="text/javascript" src="https://form.jotform.com/jsform/53284842603961"></script>
</div>

<div class="locations">
  <ul>
    <li>Gainesville</li>
    <li>Braselton</li>
  </ul>
</div>

CSS

body {
  font-family: Arial;
  padding: 20px;
  line-height: 1.5em;
  font-size: 14px;
}

JavaScript

// Read the contents of the iframe.
   var iframe = $("iframe").contents();



   // Location Bank Classes
   var locBank = [];
   $(".locations li").each(function () {
     locBank.push($.trim($(this).text().toLowerCase()))
   });
   var locBank = locBank;
   

	 
	 
	 
   // Locations Option Classes
   var locOptions = [];
   iframe.find("label:contains('Favorite') + div").find(".form-checkbox-item label").each(function () {
     locOptions.push($.trim($(this).text().toLowerCase()))
   });
   var locOptions = locOptions;
  


var locToRemove = [];

var i = 0;
jQuery.grep(locOptions, function(el) {
    if (jQuery.inArray(el, locBank) == -1) locToRemove.push(el);

    i++;
});



$.each(locToRemove, function( index, value ) {

  iframe.find("label:contains('Favorite') + div").find(".form-checkbox-item:contains('" + value +"')").hide();
	//alert(value)

});



alert(locToRemove)