This commit is contained in:
Blandine Bajard 2021-10-20 12:42:32 +02:00
parent 4a95ab8ced
commit b670aad827
2 changed files with 13 additions and 9 deletions

View File

@ -23,7 +23,7 @@
</section>
<section id="recherche">
<form action="" id="formRecherche" onSubmit="envoiForm(event); console.log('click')">
<form action="" id="formRecherche" onSubmit="event.preventDefault(); console.log('click')">
<label for="textRecherche">Recherche : </label>
<input type="text" name="textRecherche" id="textRecherche">
<input type="submit" value="ok">

View File

@ -1,7 +1,7 @@
import { api_call } from './util';
const films = document.getElementById("resultats");
const search = document.getElementById('recherche');
const search = document.getElementById('formRecherche');
const API_SEARCH = "https://swapi.dev/api/films/?search"
const API_URL = "https://swapi.dev/api/films/"; // déclare la localisation de la liste des films
@ -25,19 +25,23 @@ function remplissage(EPISODES) {
}
const accordeonItemHeader = document.querySelectorAll(".accordeon_item_header");
accordeonItemHeader.forEach(accordeonItemHeader => {
accordeonItemHeader.addEventListener("click", event => {
accordeonItemHeader.classList.toggle("active");
accordeonItemHeader.addEventListener("click", event => {
accordeonItemHeader.classList.toggle("active");
})
})
}
function envoiForm(event){
search.addEventListener("submit", ()=> {
function envoiForm(event){
console.log(search.value);
api_call(API_SEARCH+search.value, remplissage)
console.log(formenvoyé);
event.preventDefault();
api_call(API_SEARCH+search, remplissage)
console.log(formenvoyé);
}
}
})
api_call(API_URL, remplissage);