I am making a quiz app using django and it’s my first ever work using django Everything else is working fine instead of one thing which is whenever i press the button to submit the answer, page simply reloads. Here’s my html code: Here’s the js code relevance to the button: According to this…
Tag: javascript
How to group array of objects by certain prop and retain original object properties
I have an array of objects, these objects have a property that I want to group by. So my goal is to produce a new array of objects where they have all the same properties with an additional property that consolidates all the “value” properties into an array. Below is my input and desired output. H…
Add button to switch between light and dark mode using two prefers-color-scheme
I have created a page with complex design and different background colors and I decided to add a button to let users switch between light and dark mode I’ve tried different solutions with JS, but with no success. The current workaround I use is adding two media in my CSS file. Basically, if my website a…
Dynamic class binding doesn’t work in Vue
I’m using Vue2 and I face some problems with dynamic class binding (highlight in the navigation menubar the current section name in which the user is currently). I’m using the Intersection observerAPI which I initialize and let it loop over my components from the mounted() life hook. However, when…
MSAL Authentication Based on User Role
Is there a way to only authenticate users for my app that have been applied a specific role? I’m using React, Express, Node, Postgres DB. We have many members in our Active Directory, but only want to allow users that have been given one of three roles to be able to be authenticated/logged in. Is this s…
How can I get the value of an input which is a previous sibling?
I’m trying to switch a background image with a URL from a input field. With one block it works, for a second it only works if I use the first one first, or else it gets a undefined value. How do I grab the ImageUrl value for each block only? Answer There are lots of ways to traverse the DOM
Nodejs how to create a `data tree` with array on result
How to fix or redesign results or create a TreeView after mapping the result using nodejs? this is my code, please check below the desired result What I want here is that if the QuestionGroupID is existing it will not create another row but it will create array on optionItems please see the desired result vs …
Detect if server response is slow and show alert on Javascript Fetch
I would like to know if there is a way that if my request takes more than 20 seconds, I can show an alert alerting users of an error in the API. So they can refresh the page or come back later. Something like response.status. I do NOT need setTimeout and AbortController. Just detect response and trigger the a…
How can I use local variable from one function and use them in another function, if this is even possible?
My Problem I have a function called mathsFormula() which is supposed to calculate the two input fields located in the second function called renderRow() and display that answer in the <div> labelled result. However, I don’t know how to attach the local variables from renderRow() function so they w…
Convert nested array of array to nested array of object
I have currently the challenge to convert the following data: into the following: I’m currently a bit lost how I could convert the source data into the expected object. I get the data from a sql query ( presto ). The structured information ( fieldname2 and fieldname3 ) aren’t resolved, I get only …