Hello Everyone.
I have been searching all through google for materials on how to implement a preference page using Vanilla JS but i cant seems to get any material.
I will appreciate if anyone can teach me or share a link to any useful content on this topic. Thank you.
PS: Tutorial must be strictly Vanilla JS.
Where do you want to save these preferences? in browser? server?
If you want to store the preferences in client side ( assuming nothing needs to be secured ) you can simply collect your data from your form's onSubmit action then create a json data with it and save it in localStorage. something like;
<form onsubmit="save()">......</form> <script> function save(e) { e.preventDefault(); var prefs = {}; var inputs = document.querySelectorAll('input, select, textarea'), i; inputs.map(function(item) { Object.assign(prefs, {[item.name] = item.value}); }); window.localStorage.setItem('prefs', JSON.stringify(prefs)); } window.onload = function() { var prefs = JSON.parse(localStorage.getItem('prefs')); Object.keys(prefs).map(function(key) { document.querySelector(`[name=${key}]`).value = prefs[key]; }) ; } </script>it is untested, but should give you an idea