Skip to content
Advertisement

Show last 5 submitted data using only JS and HTML

I have a small question, I am yet a beginner with Java Script and I don’t have that much of knowledge with it. My question is:

I need to create a fake donation form. The form contains fields where the user can write his data like his phone number, donate amount etc… and when the user hit submit his donate amount and his name should be shown in a table, besides the last other 4 donations of the other people. I think that my code should look like that

JavaScript

I am not sure about my code, so please help me and explain to me how else I can do it. I want to keep it simple for now so please give me some advices 😀

Advertisement

Answer

I recommend you use backend language for this, like PHP, but if javaScript is what you needed, here’s a simple way for that. You can store the data in an array, or cache them so that the data will not be lost even when tab is refreshed. But let’s use array for this example. You already have your form so let’s skip it.

For the table in HTML:

JavaScript

javaScript:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement