Open LiamMyles opened 3 years ago
This is brilliant Liam. Thank you very much for your hard work. I doubt I would've ever gotten to this stage. I will learn JS! :) As for delving deeper into the code, my novice input has not yet discovered half of the js you have used above. I will however, give it a try.
I think I can see how to add the words as separate input boxes, but I'm not sure how to get the link to work correctly. I have tried previously using the # in the, but I've never got it to work correctly, yet I'll git it a go.
Finally for this stint, I see the append is being used when using the getElementbyId. To help end users use a clean form, would you normally go with a button to clear the entries, or something to clear the entries on load/refresh of the page?
No worries Dave, hopefully, this example gives you something to reference that you already mostly understand.
I'm not really sure what you mean by "Get the link to work correctly". If you elaborate on what you are trying to link to I might get a better idea.
If you want to clear the form you could use something like From.reset()
check out the docs for from.reset for more details.
But also refreshing the page will yield similar results. But honestly, as a basic thing, you could leave it for someone to fill it in and submit it a second time.
Here is the code I cleaned up.
The main thing I think you need to explore more is understanding how code gets executed in javascript.
Also, the use case for something like localstorage is often quite narrow, so if you find yourself looking to use it in this way again you might need to dig into other options first. I think in this case because the default behaviour of a form is to reload the page, it often isn't.
Anyway, I hope this helps 😁 - if you want to dig into this more feel free to respond to this GitHub thread or message me directly.