JS array to Sqlite

Hello, Here is my website: https://codepen.io/lanszelot/pen/eYarmbN?editors=1010 This template shows how the website have to work. How can I save to sqlite database the JS arrays? Each JS array into different table, but same database. I did it with php form post but after the first input the website reload itself. I try to use cookies to mark where I would like to continue the form, but it didn't work perfect. This is my hobby only, I am a beginner in sqlite and php. Thanks,
8 Replies
Jochem
Jochem•7mo ago
that's how PHP form submissions are supposed to work. They're an HTTP request to the server, which then responds with a new page for the browser to display. you can use fetch in javascript instead of a submit button if you don't want that to happen
lanszelot
lanszelotOP•7mo ago
First of all thank you for your response. As you could see there is no php form there. I am wondering how could I solve with that on codepen.
Jochem
Jochem•7mo ago
the form submission is no different, if you use a button type="submit" it'll cause a page refresh. That's part of the basic functioning of the web. You've got a ton of markup and the text is in a language I don't speak, so I'm not going to dig through it all
lanszelot
lanszelotOP•7mo ago
In the codepen there is no submit at all, and no form. vege function at the bottom have all arrays what I have to save to sqlite.
b1mind
b1mind•7mo ago
Why not a real form 🥲
lanszelot
lanszelotOP•6mo ago
Hi, My question was: how can I save "vege" function arrays in sqlite database, each array different table. Not: how can I do it different way. :thumbup:
b1mind
b1mind•6mo ago
I would still use a real form period that is what they are there for semantics and function https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData FormData API on a form submit, either way to use sqlite you will need to send the action to the backend. You can choose how to do this in JS by e.preventDefaulting the submit event, storing it clientside, but you will still need to send a POST request to your server yes? We might be unclear in your question cause it does not make a lot of sense to either of us. Jochem is pointing out that is how things work, I'm pointing out you should always use <form>s for forms 😉
Jochem
Jochem•6mo ago
you're asking a question which includes the explicit disclaimer that you're a beginner / hobbyist, so people are going to suggest better solutions. They'd even do that if you said you were an expert. Please just accept that and save the snarky replies for another server
Want results from more Discord servers?
Add your server