From the course: JavaScript: Client-Side Data Storage

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add new items to IndexedDB

Add new items to IndexedDB - JavaScript Tutorial

From the course: JavaScript: Client-Side Data Storage

Start my 1-month free trial

Add new items to IndexedDB

- [Narrator] Now we've got everything we need to be able to start adding new items to our database, so let's get to it. The next step is to start creating a function that will actually add new data. So let's go ahead and do that. So we'll create a function called adddata, which will take an event. And then the first thing we'll do is prevent default. Because you don't want the browser to refresh when you do that. Then we'll create a new item, which will be a variable that will hold the values that we get from the submission. So first name, which will take the first name input dot value. So remember we created a variable here. First name input that will pull from the first name ID on our form. And then the same for the last name. So let's copy that here. And then comma paste and then change last name. So option click and just do last name, like this. Now that we've created a variable or an object that holds this information, we can work with it. So everything works with transactions…

Contents