Nar
Nar
KPCKevin Powell - Community
Created by Nar on 7/15/2024 in #front-end
Why Bootstrap Styles Are Not Active
No description
4 replies
KPCKevin Powell - Community
Created by Nar on 3/27/2024 in #front-end
can somebody tell me the correct path for this image?
No description
21 replies
KPCKevin Powell - Community
Created by Nar on 6/13/2023 in #front-end
Pass ID
Hello, I'm a beginner So, I want to pass ID in order to dynamically display item desc based on clicked card. I ask chat gpt and it gave me code below. Everything looks fine until I try to run the code manually (without live server extensions) and got all sort of error such as: "Access to script at 'file:///C:/Users/Asus/.../passID.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted." How I can fix it? Thanks in advance
<script type="module" src="passID.js"></script>
<script type="module" src="passID.js"></script>
// Get all the card elements
const cardElements = document.querySelectorAll('.animal-card');

// Add a click event listener to each card element
cardElements.forEach(card => {
card.addEventListener('click', event => {
// Get the ID of the clicked element
const id = event.currentTarget.id;

// Encode the ID for use in the URL
const encodedSearchQuery = encodeURIComponent(id);

// Redirect to the detail page with the encoded ID in the URL parameter
window.location.href = `/animal-detail.html?searchQuery=${encodedSearchQuery}`;
});
});
// Get all the card elements
const cardElements = document.querySelectorAll('.animal-card');

// Add a click event listener to each card element
cardElements.forEach(card => {
card.addEventListener('click', event => {
// Get the ID of the clicked element
const id = event.currentTarget.id;

// Encode the ID for use in the URL
const encodedSearchQuery = encodeURIComponent(id);

// Redirect to the detail page with the encoded ID in the URL parameter
window.location.href = `/animal-detail.html?searchQuery=${encodedSearchQuery}`;
});
});
15 replies