I painted this picture to demonstrate what my final goal is.
Short description:
- If nothing is changed in form or there's already exact same values saved, "save values" button does nothing
- If something is changed in form, "save values" button saves those values to localStorage and bind with numbered element ("1" in picture) and with input it came from
- If numbered element is clicked, it fills the inputs that were changed with values that were saved
- If something is changed in form & it's not the same as already saved values, "save values" button saves to element 2
- Red "X" in numbered element deletes saved values from localStorage binded to that element
Im not here to get the whole working solution from you guys, don't worry. I've researched for a week & I can't wrap my mind around it. It would be easy without binding to elements & "grouping".
Questions:
- How to bind localStorage values to numbered elements and also to input fields it first came from?
- How to "treat" saved values in localStorage as group which is binded to numbered element? For example: delete values only binded to that numbered element if delete is pressed.
- How to check if same values already exist (also taking into account many values, it's easy with 1)?
This question shows how to set & get value to/from localStorage.
This question shows how to remove value from localStorage.
This question shows how to check if localStorage value exists.