Keeping Score of quiz in javascript website [closed] - javascript

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
We are creating a website in which homework (with about 10 multiple choice questions) will be graded. Each question is on their own HTML page. How do we tally the overall grade of the homework, while keeping track of each multiple choice question? (Deduct .33 points twice if wrong, then tally that score to a total score for the homework)

You need to have some state to persist the answers. There are a number of options including:
save the answer to the server for each question
save the answer to localStorage
save the answer in a cookie
save the answer in the URL as a query parameter
If you prefer to stay client side, I suggest using localStorage. It is a key-value store with some limitations on size but it should be a good fit for your problem.
My approach would be to store the answer into localStorage for each question. On the final page, I would load all the answers and perform the calculation for points.
MDN: localStorage

Related

javascript not loading image error::ERR_FILE_NOT_FOUND [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
Hey guys i am building dice roller website using random in javascript but after setting attributes for dice image i am getting file not found error.Images are stored like images/dice.png
your actualy seting the image's source to the str randomImg rather then the variable's value what you want to do is remove the "" that make it a string and use the variable
so the last line of the js would look like document.querySelectorAll[0].setAttribute('src',randomImg)

Real time website information/content updating [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Since a year and a half I am trying to figure out how some websites update their content in real time without AJAX method.
Please see this example website: https://pro.btcturk.com/en/basic/exchange/BTC_TRY
That website is changing many texts within content in different timing.
It means that when the server is updated with new values in the database then the website is listening to database changes and then reflecting/delivering inside content without ajax calls.
Can someone give an example how to achieve such functionality possibly using Javascript or PHP normal hand-code appreciated?
Thank you
You can see the process here:
More information here: Websockets

How to update value in realtime database in Firebase using JS [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
This is what my database looks like:
My question is how to I decrement the value of FIELD11 i.e. "4" in my realtime database in Firebase using javascript, everytime I click on DECREMENT Button on my html page it should decrement this value and get updated in realtime database. Thank You
I recommend you use a Firebase transaction.
When working with data that could be corrupted by concurrent modifications, such as incremental counters, you can use a transaction operation.
Example:
https://firebase.google.com/docs/database/web/read-and-write#save_data_as_transactions

ReactJS how to persist state in cookies [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Below is sample example for counter but i have to maintain the state after page is refree.For example i will increment the counter to 10 and next time when my page refreshes the page should start with 10 instead of 1.
Can anyhow guide me regarding this.
If you want to use cookies JS-cookie is really handy. Setting and retrieving cookie is really easy.
Use localStorage for that.
In your action handler do:
let counter = window.localStorage.getItem("counter");
window.localStorage.setItem("counter ", ++counter);
Then in your componentDidMount do:
let counter = window.localStorage.getItem("counter");
this.setState("counter", counter);

How do I create a simple javascript server? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to create a server where if I pressed "w", a variable (lets say me1) would equal to 1. And if another user (from a different browser and IP) pressed the same key, another variable (lets say other2) would equal to 1.
I don't need everything to be JavaScript (as long as it's easy to understand), I just need the end variables to be JavaScript.
Do your users from different IP's need to be able to talk to each other?
You could use NodeJS as one way to do this. I only recommend Node because its very simple to setup sockets if your answer to my above question is yes.
However both technologies would require a medium to advanced skill set.

Categories