Skip to content

Instantly share code, notes, and snippets.

@ESeufert
Created May 2, 2014 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ESeufert/2a18200dd2eb615cb522 to your computer and use it in GitHub Desktop.
Save ESeufert/2a18200dd2eb615cb522 to your computer and use it in GitHub Desktop.
function buildConsole(data) {
var html = "";
html += "<div id=\"country-selector\" class=\"console-element\">";
for (var i = 0; i < data.length; i++) {
html += "<div style=\"width: 150px; float: left;\">";
html += "<input name=\"countries\" id=\"country-selector-" + data[i][0] + "\" type=\"checkbox\" ";
if (i == 0) {
html += "checked"; // set the first country to checked to provide some default data for the graphs
}
html += " value=\"" + data[i][0] + "\" /> ";
html += data[i][0];
html += "</div>";
}
html += "</div>";
$('#console').html(html);
}
function getCountries() {
var elements = $("input:checkbox[name=countries]:checked");
var countries = [];
$.each(elements, function () {
countries.push($(this).val());
});
return countries;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment