Last active
December 22, 2016 15:27
-
-
Save toddheslin/3b8b51d3d48e4568af09 to your computer and use it in GitHub Desktop.
Revisions
-
Todd Heslin revised this gist
Feb 27, 2015 . 1 changed file with 58 additions and 48 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,59 +1,69 @@ /* // The following code is from @dorward answering a stackoverflow question. // Like the Wufoo embed, it doesn't rely on jQuery. Thanks @dorward! */ <div id="wufoo-m2oq9xw0yusu89"></div> <script type="text/javascript"> var QueryString = function () { /* This function is anonymous, is executed immediately and the return value is assigned to the variable 'QueryString' */ var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(pair[1]); } } return query_string; } (); /* For this part down, it's best to copy the script from your wufoo admin panel however pay close attention to the if statement below and the defaultValues in the first 'if code block' */ var m2oq9xw0yusu89;(function(d, t) { if (window.location.search === ""){ var s = d.createElement(t), options = { 'userName':'beingremarkable', 'formHash':'m2oq9xw0yusu89', 'autoResize':true, 'height':'828', 'async':true, 'host':'wufoo.com', 'header':'hide', 'ssl':true}; s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js'; s.onload = s.onreadystatechange = function() { var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return; try { m2oq9xw0yusu89 = new WufooForm();m2oq9xw0yusu89.initialize(options);m2oq9xw0yusu89.display(); } catch (e) {}}; var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr); } else { var s = d.createElement(t), options = { 'userName':'beingremarkable', 'formHash':'m2oq9xw0yusu89', 'autoResize':true, 'height':'828', 'async':true, 'host':'wufoo.com', 'header':'hide', 'ssl':true, 'defaultValues': 'field1=' + QueryString.cool}; s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js'; s.onload = s.onreadystatechange = function() { var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return; try { m2oq9xw0yusu89 = new WufooForm();m2oq9xw0yusu89.initialize(options);m2oq9xw0yusu89.display(); } catch (e) {}}; var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr); } })(document, 'script'); </script> -
Todd Heslin created this gist
Nov 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ <script> // The following code is from @dorward answering a stackoverflow question. // Like the Wufoo embed, it doesn't rely on jQuery. Thanks @dorward! var QueryString = function () { // This function is anonymous, is executed immediately and // the return value is assigned to QueryString! var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(pair[1]); } } return query_string; }(); // for this part down, best to copy the script from your wufoo admin panel however pay close attention to the if statement below and the defaultValues in the first 'if code block' var z7zupww0vb98kb; (function(d, t) { // ensure you update 'first' and 'last' with the variables you are looking for in the URL. Change this expression if you require more variables to be present before you load the default Values in if (window.location.search === ""){ var s = d.createElement(t), options = { 'userName':'######', //this is your username for Wufoo 'formHash':'######', //this is your form hash from wufoo 'autoResize':true, 'height':'540', 'async':true, 'host':'wufoo.com', 'header':'hide', 'ssl':true, //replace 'first' and 'last' with the names of the params within your url 'defaultValues':'field1='+QueryString.first+'&field2='+QueryString.last}; } else { var s = d.createElement(t), options = { 'userName':'#####', // same as above 'formHash':'#####', // same as above 'autoResize':true, 'height':'540', 'async':true, 'host':'wufoo.com', 'header':'hide', 'ssl':true}; }; s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'www.wufoo.com/scripts/embed/form.js'; s.onload = s.onreadystatechange = function() { var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return; try { z7zupww0vb98kb = new WufooForm();z7zupww0vb98kb.initialize(options);z7zupww0vb98kb.display(); } catch (e) {}}; var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr); })(document, 'script'); </script>