Created
February 28, 2017 11:44
-
-
Save jonolayton/c0efc76d9f4f42b0ee2756c001ef272c to your computer and use it in GitHub Desktop.
Full code snippet
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 characters
$(document).ready(function() { | |
$("#multi").submit(function(e) { | |
e.preventDefault(); | |
$("#output").empty(); | |
var array1 = []; | |
var array2 = []; | |
var array3 = []; | |
$(".col1").each(function() { | |
var word1 = $(this).val(); | |
if ( word1 !== "" ) { | |
//word1 = word1.replace(/\s+/g, ''); | |
array1.push(word1); | |
} | |
}); | |
$(".col2").each(function() { | |
var word2 = $(this).val(); | |
if ( word2 !== "" ) { | |
//word2 = word2.replace(/\s+/g, ''); | |
array2.push(word2); | |
} | |
}); | |
$(".col3").each(function() { | |
var word3 = $(this).val(); | |
if ( word3 !== "" ) { | |
//word3 = word3.replace(/\s+/g, ''); | |
array3.push(word3); | |
} | |
}); | |
console.log(array1); | |
console.log(array2); | |
console.log(array3); | |
var outData = []; | |
var outPlus = []; | |
$(array1).each(function( a, b ) { | |
$(array2).each(function ( c, d ) { | |
outData.push( b + " " + d ); | |
$(array3).each(function( e, f ) { | |
outData.push( b + " " + d + " " + f ); | |
}); | |
}); | |
}); | |
console.log(outData); | |
if ( $("input[name='bmm']").prop("checked") == true ) { | |
$(outData).each(function( g, h ) { | |
outPlus.push( h.split(" ") ); | |
}); | |
console.log(outPlus); | |
$(outPlus).each(function( i, j ) { | |
var output = j.replace(/(^|\s)/g, '$1+'); | |
console.log(j); | |
}); | |
} | |
console.log(outPlus); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment