0
Lock and unlock
Hi guys, I need help with lock and unlock exercise. Something like Sololearn have. You need to finish part 1 to go to part 2. Part 1 is unlock and part 2 is lock. Part 2 opens when you finish part 1. I hope I explained well. If you have some doubts ask me. How to do it in Html, Javascript, Jquery. Somebody have a tips?
1 Resposta
+ 2
Mostly, what I would do is, make global variables like `part1_completed`, `part2_completed` and set them to false by default. Then, if someone completed part 1, simply set `part1_completed` to true. If someone tries to access part 2 and `part1_completed` is false, then simply stop them. But if `part1_completed` is true, they can access part 2.
If you don't have a fixed number of parts or a lot of parts, you can make an array with capacity equal to the number parts and set each index to false. You can use a variable `currentPart` to keep track of the current uncompleted part. When the user completes a part, set value of array of parts at index currentPart to true. If the value of array at index currentPart is true, then only one can access part currentPart + 1.
For questions like these, it is recommended to go the "Codes" tab and look for codes similar to what you need there.
Also, please remove the c# tag as it has no significance in your question.