Created
July 7, 2019 16:38
-
-
Save YuraKolesnikov/928f6f4e6014aa87c36a9ff88843880e to your computer and use it in GitHub Desktop.
Select on change fetch
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<select name="category" id="category-select"> | |
<option value="" disabled selected>Please select the category</option> | |
<option value="tv">TV</option> | |
<option value="computers">Computers</option> | |
<option value="phones">Phones</option> | |
<option value="games">Videogames</option> | |
</select> | |
<script> | |
const categorySelect = document.getElementById('category-select') | |
categorySelect.addEventListener('change', e => { | |
const currentCategory = e.target.value | |
/* Вот здесь пойдет запрос на бэкенд, посылаешь currentCategory */ | |
console.log(currentCategory) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment