Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>List of candidates</h1>
<select onChange="processCandidates(this)">
  <option></option>
  <option value="CK">Chambre / Kamer
  <option value="VL">Parlement flamand / Vlaams Parlement
  <option value="WL">Parlement régional wallon / Waals Parlement
  <option value="BR">Parlement de la Région de Bruxelles-Capitale / Brussels Hoofdstedelijk Parlement
  <option value="DE">Parlement de la Communauté germanophone / Parlement van de Duitstalige Gemeenschap
  <option value="EU">Parlement européen / Europese Parlement
</select>
<ul id="candidates">
  
</ul>
              
            
!

CSS

              
                
              
            
!

JS

              
                /**
 *  @param type is one of the following: 
      - CK : Chambre / Kamer
      - VL : Parlement flamand / Vlaams Parlement
      - WL : Parlement régional wallon / Waals Parlement
      - BR : Parlement de la Région de Bruxelles-Capitale / Brussels Hoofdstedelijk Parlement
      - DE : Parlement de la Communauté germanophone / Parlement van de Duitstalige Gemeenschap
      - EU : Parlement européen / Europese Parlement
 */ 
var getCandidates = async function (type) {
  let response = await fetch('https://api.elections.openknowledge.be/format-i/candidates/2019/' + type);
  return await response.json();
};

//***************** Stop of convenience functions ********************
//Example usage in a view
function processCandidates(e) {
  let election = e.value;
  let htmlList = document.getElementById('candidates');
  htmlList.innerHTML = "Retrieving list of candidates";
  getCandidates(election).then((candidates) => {
    htmlList.innerHTML = "";
    for (let i in candidates) {
      let candidate = candidates[i]; 
      // console.log(candidates[i]);
      let element = '<li>' + candidate.name + ' - ' + candidate.list.name + '</li>';
      htmlList.innerHTML += element;
    }
  });
}

              
            
!
999px

Console