<h1>Compare Congress</h1>
<ol>
<li>Select a Politician to be compared</li>
<li>Select a Second Politician to be Compared Against</li>
<li>Vote for Neither: Vote Pirate Party</li>
</ol>
<select name="person1">
</select>
<button class="show">Choose 2nd Politician</button>
<select name="person2">
</select>
CSS
/** hide second list of options from user until first selection has been made **/
select[name="person2"]{display:none}
JavaScript
$(document).ready(function () {
$.getJSON("https://congress.api.sunlightfoundation.com/legislators?per_page=all&apikey=ebbe9f8409134303aab01479e8f1a42f", function (data) {
$.each(data.results, function () {
var ele = $("<option>").attr('value', this['bioguide_id'])
.text(this['first_name'] + " " + this['last_name']);
$("select").append(ele.clone());
// show 2nd list of options only after user has selected first. doing this with button and not on selection because user could easily make
// an erroneous choice
// another option here is to grey it out until the button is clicked....
$(".show").click(function() {
$("select[name='person2']").show();
});
});
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.