SQLite what is the correct way?
Hello,
I would like to store data with SQLite after a few steps.
Example : first page I ask name and age, second page birth and gender, third page ....so on.
Till the last page.
But I would like to store data only when someone finished all pages.
If close the browser, or did not finished somehow I do not want to store that data.
Should I have to store temporary data in Local Storage, and on the last page when finished read data from Local Storage and write in SQLite database?
Or what is the correct way to do this?
19 Replies
store unfinished progress in local storage
then when the user finishes, you send a request to the backend
whatever you do there, is up to you
and there, you can store the data in sqlite
Instead of multiple pages, do pagination on onepage via tabs or something.
Then you store the info in memory via a JavaScript object and send it all to your server in swoop.
Or have it be one form so you don’t need to save anything and it’s a simple form submission to your server.
You can use the
:target
pseudo-class to show/hide parts of the page:
https://developer.mozilla.org/en-US/docs/Web/CSS/:targetFirst of all thank you for responding to everyone.
Cannot do on one page, it must have to be multiple pages.
The example was only an example, the imagined site is more difficult.
This is why I asked what is the correct way.
I had lot of ideas how can I solve it, but I don't know how it have to be.
Example my other idea is to make a "done" data in the database, and the last page write in the database "done".
Every read check "done" , if it is missing delete those datas.
So I can solve it, but what is the correct way?
Cannot do on one page, it must have to be multiple pages.why?
There are parts which have to jump over if not exist.
Example do you have brother, if no, no questions about brother.
And the page will be too much scroll over
I tried with display-none , but it is not working and got errors.
That’s doable on one page. Pay simple if check. If yes, display questions about brother. If no, don’t display
That’s a good reason to ask for help. Not to make a form multi-pages
I asked, about half year ago, and the answer was need multiple pages
I started this project from the beginning 4 times. First I start one page , it was a huge mess. After one page with not displayed elements, I could create error. So I had to restart again still tried to use one page, but no. Then I got answered , I had to use multiple pages. So I started again with multiple pages, and worked well, but
I don't like how it is working.
Hmm…well, you can do it that way if the form is long enough and you have a “save and come back later” feature. Which is basically saving state in LocalStorage.
Can you give us a bit more info about the form? How many questions? How many branches? Stuff like that.
If we know more about what you’re doing we can better advise on how to do it well
There is no "save and come back"
I didn't think about that.
Could be good idea.
I am creating project only for myself, coding is my hobbie , no-one see my sites. I just create for fun.
Most of them are stipid sites.
Like this idea: my partner home pastry recipes are in an old notebook.
I thought to create a site where she can write from the notebook. She will never do it, but website idea.
Ok, so why would a recipe site need to ask all those questions about your family and siblings?
Your question doesn't seem to have anything to do with your use case. So until you ask you actual question about what you're actually doing we can't help you.
You want a proper "Step Form"
You would probably just do it all client side, single page, then send formData() back to the server on final step :think:
This is one those few cases where I'm going to advicate against using multiple pages for a form. Now if you were saving each step to the DB then we are talking each page submits the formData() to the BE
Step forms a fun but really big debate how great of UX they are.
You have to ask what is the main benefit from one.... a user does not have to scroll to fill out any info, and its simplified input to focus on.
I would really only use one if you are doing many multiple inputs too honestly ... one input per step? naw just make a form...
https://www.w3schools.com/howto/howto_js_form_steps.asp
Here is a amazing example of what I would consider a bad step form 🤣
I mean semi pointless
You also have to keep in mind what auto fills for people
if all this was on one page one form many inputs... a user can just hit complete and boom submit
The only time I find them at all helpful is like if you needed it for some reason on the backend and or if the Steps were part of something you needed people to really focus on. I.e. Getting air filters for your home, tires for your car, stuff where it needs to return with more info based on your first inputs.
yikes! not only a bad "step form" (a.k.a wizard), but a terrible implementation as well
Depending on the data, a simple
application/x-www-form-urlencoded
would suffice. FormData
is really only needed if you're sending binary files. If it's text only form url encoded or JSON would be a lot easier to work with.What about the form makes it so bad ? Is it because there's only a few questions per step and it could all be done at once ? Haven't looked at the code so maybe thats where the "bad" comes in ?
it's an user registration form
imagine doing a multi-step form just to be able to login into a website
the most irritating is the "let us know how you will use this"
and then you have 5-6 steps that make 0 difference
Because there is no actual steps, the inputs from step 1 don't effect step 2 and so on. Like I pointed out above too, for those specific inputs a user could just use auto fill in a single form and be done. Being a step form it's just more annoying.
First of all thank you for your response to all of you.
I wrote example to explain what would I want to do.
I do not ask name or those things what is in the example, that is only an example. The site is more complex
Json file not good, because it would be too big.
I do not have code, because I have to know how to collect data, and make the site on it.
I can share old site, I try to found it some6
But my question is still the same: what is the proper way to store multiple sites data whit the condition what I mentioned?
Please understand: no one will use auto fill. No one will use my site. I do it only for chilling, to relax, for hobby. No one use my sites, no one know about my sites, no one care about my sites. Those are stupid sites. It is for me to relax only. 🙂
As you practice, so shall you do
Practice makes habitJust because "no one will see it" doesn't mean you should teach yourself bad habits
Here is the old site: https://codepen.io/lanszelot/pen/EajmNNw