Skip to content

Instantly share code, notes, and snippets.

@tassioauad
Created April 13, 2020 12:33
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 tassioauad/4733a67e436e4e22f3d0e43d26805dbd to your computer and use it in GitHub Desktop.
Save tassioauad/4733a67e436e4e22f3d0e43d26805dbd to your computer and use it in GitHub Desktop.
{% extends 'base.html' %}
{% block body %}
<nav class="navbar navbar-light bg-light">
<span class="navbar-text">
Matriz Curricular
</span>
<select class="custom-select col-md-2" id="periodo-list">
<option selected>Selecione um Período</option>
{% for periodo in periodo_list %}
<option value="{{periodo.get_id()}}">{{periodo.get_nome()}}</option>
{% endfor %}
</select>
</nav>
<div id="periodo"></div>
<script>
var getPeriodo = function(periodoId) {
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
document.getElementById("periodo").innerHTML = xhr.response;
}
}
xhr.open("GET", "/periodo?numero=" + periodoId);
xhr.setRequestHeader("Accept", "text/html")
xhr.send();
}
let selectList = document.getElementById("periodo-list");
getPeriodo(1);
selectList.addEventListener('change', getPeriodo(selectList.value));
</script>
{% endblock%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment