Created
April 13, 2020 12:33
-
-
Save tassioauad/4733a67e436e4e22f3d0e43d26805dbd to your computer and use it in GitHub Desktop.
This file contains 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
{% 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