How to save information from javascript to Microsoft Access database?


I would like to save my user’s input to a database.

In my project from my studies I encountered a problem saving information in the javascript language .

I founded a function on the internet that captures the variable and converts it to a string
to json file, but it didnt create the file with the input.

the function :

  <script>
         let account= [];
        
        const addAccount = (ev)=>{
            ev.preventDefault();  //to stop the form submitting
            let accounts = {
                first_name:document.getElementById('first_name').value,
                last_name:document.getElementById('last_name').value,
                id:document.getElementById('id').value,
                password:document.getElementById('password').value,
                co_password:document.getElementById('co_password').value,
                email:document.getElementById('email').value,
                contact:document.getElementById('contact').value,
                role:document.getElementById('role').value
            }
            accounts.push(account);
            document.forms[0].reset(); // to clear the form for the next entries
            //document.querySelector('form').reset();
    
            //for display purposes only
            console.warn('added' , {accounts} );
            let pre = document.querySelector('#msg pre');
            pre.textContent = 'n' + JSON.stringify(accounts, 't', 2);
    
            //saving to localStorage
            localStorage.setItem('MyAccountList', JSON.stringify(accounts) );
        }
        document.addEventListener('DOMContentLoaded', ()=>{
            document.getElementById('btn').addEventListener('click', addAccount);
        });
    </script>

of course I allready have an register order in the same HTML file.

So the question is how I save at data in local storage in json file ?

Thank you.

Source: JavaSript – Stack Overflow

November 28, 2021
Category : News
Tags: database | html | javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.