Spaces:
Running
Running
| document.addEventListener("DOMContentLoaded", () => { | |
| const formContainer = document.getElementById("form-container"); | |
| // Fetch all forms from the backend | |
| fetch('https://iacelectricals-backendrmitem.hf.space/getForms') | |
| .then(response => response.json()) | |
| .then(forms => { | |
| forms.forEach(form => { | |
| const formCard = document.createElement("div"); | |
| formCard.classList.add("form-card"); | |
| formCard.innerHTML = ` | |
| <h3>${form.formName}</h3> | |
| <p>${form.formDescription}</p> | |
| <a href="${form.formLink}" target="_blank" class="button">Open Form</a> | |
| `; | |
| formContainer.appendChild(formCard); | |
| }); | |
| }) | |
| .catch(error => { | |
| console.error("Error fetching forms:", error); | |
| formContainer.innerHTML = "<p>Unable to load forms. Please try again later.</p>"; | |
| }); | |
| }); | |