JS - I want to create a dropdown filter menu for my events
up vote
0
down vote
favorite
I'm pretty new to coding with JS, so I can't seem to find out how to create a dropdown filtermenu that can filter the content to show only certain events on my page.
Ask away if you need more information, this is also my 1st Stackoverflow post, so I don't know how much to include.
Thank you in advance!
HTML
<section id="events">
<main>
<section class="container" data-container></section>
<template data-template>
<article class="postListview">
<div class="card middle">
<div class="front">
<img src="" alt="">
</div>
<div class="back">
<div class="back-content middle">
<h2 data-title></h2>
<div data-text></div>
<div data-pris></div>
<div data-tid></div>
<div data-sted></div>
</div>
</div>
</div>
</article>
</template>
</main>
JS
<script>
document.addEventListener("DOMContentLoaded", getJSON);
let posts;
let postTemplate = document.querySelector("[data-template]");
let postContainer = document.querySelector("[data-container]");
async function getJSON() {
let jsonData = await fetch("http://www.rigmordesign.com/kea/huset/wordpress/wp-json/wp/v2/events");
posts = await jsonData.json();
visPosts();
}
function visPosts() {
console.log(posts);
posts.forEach(post => {
let klon = postTemplate.cloneNode(true).content;
klon.querySelector("[data-title]").textContent = post.title.rendered;
klon.querySelector("[data-text]").innerHTML = post.content.rendered;
klon.querySelector("[data-pris]").innerHTML = post.acf.pris;
klon.querySelector("[data-tid]").innerHTML = post.acf.tid;
klon.querySelector("[data-sted]").innerHTML = post.acf.sted;
klon.querySelector("img").src = post.acf.billede;
postContainer.appendChild(klon);
})
}
</script>
javascript
add a comment |
up vote
0
down vote
favorite
I'm pretty new to coding with JS, so I can't seem to find out how to create a dropdown filtermenu that can filter the content to show only certain events on my page.
Ask away if you need more information, this is also my 1st Stackoverflow post, so I don't know how much to include.
Thank you in advance!
HTML
<section id="events">
<main>
<section class="container" data-container></section>
<template data-template>
<article class="postListview">
<div class="card middle">
<div class="front">
<img src="" alt="">
</div>
<div class="back">
<div class="back-content middle">
<h2 data-title></h2>
<div data-text></div>
<div data-pris></div>
<div data-tid></div>
<div data-sted></div>
</div>
</div>
</div>
</article>
</template>
</main>
JS
<script>
document.addEventListener("DOMContentLoaded", getJSON);
let posts;
let postTemplate = document.querySelector("[data-template]");
let postContainer = document.querySelector("[data-container]");
async function getJSON() {
let jsonData = await fetch("http://www.rigmordesign.com/kea/huset/wordpress/wp-json/wp/v2/events");
posts = await jsonData.json();
visPosts();
}
function visPosts() {
console.log(posts);
posts.forEach(post => {
let klon = postTemplate.cloneNode(true).content;
klon.querySelector("[data-title]").textContent = post.title.rendered;
klon.querySelector("[data-text]").innerHTML = post.content.rendered;
klon.querySelector("[data-pris]").innerHTML = post.acf.pris;
klon.querySelector("[data-tid]").innerHTML = post.acf.tid;
klon.querySelector("[data-sted]").innerHTML = post.acf.sted;
klon.querySelector("img").src = post.acf.billede;
postContainer.appendChild(klon);
})
}
</script>
javascript
whats the problem?
– Joe Warner
Nov 7 at 23:03
I made the elements show up in my DOM using JS, but I wanted to create a dropdown button / menu that can filter the elements to show only a specific location if selected (I have 4 different locations which the events are also labeled in my JSON file)
– Rasmus Kjeldsen
Nov 7 at 23:10
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm pretty new to coding with JS, so I can't seem to find out how to create a dropdown filtermenu that can filter the content to show only certain events on my page.
Ask away if you need more information, this is also my 1st Stackoverflow post, so I don't know how much to include.
Thank you in advance!
HTML
<section id="events">
<main>
<section class="container" data-container></section>
<template data-template>
<article class="postListview">
<div class="card middle">
<div class="front">
<img src="" alt="">
</div>
<div class="back">
<div class="back-content middle">
<h2 data-title></h2>
<div data-text></div>
<div data-pris></div>
<div data-tid></div>
<div data-sted></div>
</div>
</div>
</div>
</article>
</template>
</main>
JS
<script>
document.addEventListener("DOMContentLoaded", getJSON);
let posts;
let postTemplate = document.querySelector("[data-template]");
let postContainer = document.querySelector("[data-container]");
async function getJSON() {
let jsonData = await fetch("http://www.rigmordesign.com/kea/huset/wordpress/wp-json/wp/v2/events");
posts = await jsonData.json();
visPosts();
}
function visPosts() {
console.log(posts);
posts.forEach(post => {
let klon = postTemplate.cloneNode(true).content;
klon.querySelector("[data-title]").textContent = post.title.rendered;
klon.querySelector("[data-text]").innerHTML = post.content.rendered;
klon.querySelector("[data-pris]").innerHTML = post.acf.pris;
klon.querySelector("[data-tid]").innerHTML = post.acf.tid;
klon.querySelector("[data-sted]").innerHTML = post.acf.sted;
klon.querySelector("img").src = post.acf.billede;
postContainer.appendChild(klon);
})
}
</script>
javascript
I'm pretty new to coding with JS, so I can't seem to find out how to create a dropdown filtermenu that can filter the content to show only certain events on my page.
Ask away if you need more information, this is also my 1st Stackoverflow post, so I don't know how much to include.
Thank you in advance!
HTML
<section id="events">
<main>
<section class="container" data-container></section>
<template data-template>
<article class="postListview">
<div class="card middle">
<div class="front">
<img src="" alt="">
</div>
<div class="back">
<div class="back-content middle">
<h2 data-title></h2>
<div data-text></div>
<div data-pris></div>
<div data-tid></div>
<div data-sted></div>
</div>
</div>
</div>
</article>
</template>
</main>
JS
<script>
document.addEventListener("DOMContentLoaded", getJSON);
let posts;
let postTemplate = document.querySelector("[data-template]");
let postContainer = document.querySelector("[data-container]");
async function getJSON() {
let jsonData = await fetch("http://www.rigmordesign.com/kea/huset/wordpress/wp-json/wp/v2/events");
posts = await jsonData.json();
visPosts();
}
function visPosts() {
console.log(posts);
posts.forEach(post => {
let klon = postTemplate.cloneNode(true).content;
klon.querySelector("[data-title]").textContent = post.title.rendered;
klon.querySelector("[data-text]").innerHTML = post.content.rendered;
klon.querySelector("[data-pris]").innerHTML = post.acf.pris;
klon.querySelector("[data-tid]").innerHTML = post.acf.tid;
klon.querySelector("[data-sted]").innerHTML = post.acf.sted;
klon.querySelector("img").src = post.acf.billede;
postContainer.appendChild(klon);
})
}
</script>
javascript
javascript
asked Nov 7 at 22:58
Rasmus Kjeldsen
1
1
whats the problem?
– Joe Warner
Nov 7 at 23:03
I made the elements show up in my DOM using JS, but I wanted to create a dropdown button / menu that can filter the elements to show only a specific location if selected (I have 4 different locations which the events are also labeled in my JSON file)
– Rasmus Kjeldsen
Nov 7 at 23:10
add a comment |
whats the problem?
– Joe Warner
Nov 7 at 23:03
I made the elements show up in my DOM using JS, but I wanted to create a dropdown button / menu that can filter the elements to show only a specific location if selected (I have 4 different locations which the events are also labeled in my JSON file)
– Rasmus Kjeldsen
Nov 7 at 23:10
whats the problem?
– Joe Warner
Nov 7 at 23:03
whats the problem?
– Joe Warner
Nov 7 at 23:03
I made the elements show up in my DOM using JS, but I wanted to create a dropdown button / menu that can filter the elements to show only a specific location if selected (I have 4 different locations which the events are also labeled in my JSON file)
– Rasmus Kjeldsen
Nov 7 at 23:10
I made the elements show up in my DOM using JS, but I wanted to create a dropdown button / menu that can filter the elements to show only a specific location if selected (I have 4 different locations which the events are also labeled in my JSON file)
– Rasmus Kjeldsen
Nov 7 at 23:10
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53199179%2fjs-i-want-to-create-a-dropdown-filter-menu-for-my-events%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
whats the problem?
– Joe Warner
Nov 7 at 23:03
I made the elements show up in my DOM using JS, but I wanted to create a dropdown button / menu that can filter the elements to show only a specific location if selected (I have 4 different locations which the events are also labeled in my JSON file)
– Rasmus Kjeldsen
Nov 7 at 23:10