SQLite checkboxes how to?
Hello,
I am wondering how to store more checkbox datas with checkbox only no submit button or else?
So, when checkbox changeing, change the database straight away.
No need to push submit button, or anything else.
I would like to use sqlite, php only.
I know this code is not working and it is wrong, but I share only because this is how long I reached.
I tried to figure out, but no luck.
43 Replies
you'll need to attach a listener to the change event on the form using javascript
that listener then sends a request to the server to actually store it in the database
I know but I have no idea how to
i wouldnt do that, it's an easy way to ddos your database
that's a bit much. Lots of apps store things automatically without having to click save
if it becomes an issue, you can cache and save the requests until there have been no changes for a few seconds
yes, but they dont do inserts and deletes for thst
I do not want to use js
then you're SOL
this needs JS
then you cant
there is a hacky way, but it is so abysmally bad i dont think i should share
So I coul not use POST with checkboxes? Only with button?
that question doesnt make sense, im sorry
correct
you can only trigger a form submit with a submit button, or javascript
I see
the alternative non-js way is to not use checkboxes, but links that send you to a PHP page that toggles the state and rerenders the entire page after with the "checkbox" flipped, but that's a Bad Idea™️
Why do you want to avoid Javascript so much?
i have a hacky awful idea
don't 😛
I have no idea how can I work php and js together
PHP generates the HTML that's shown in the browser, JS runs in the browser. That's it
there's no magic
if you need to communicate between the two, you use
fetch
in JSand then you have some url that you send ajax/fetch requests to
yes I know this, but php and js run different time, not together, and I cannot use fetch at all, I cannot understand it. I tried many times to understand
so?
sorry, but it's kind of necessary if you want front and backend to communicate
you can't have frontend interactivity communicate with the backend without using something like fetch. XmlHttpRequest works, but it's outdated. You can use libraries like Axios, but they work much the same as
fetch
submitting forms with JS isn't a practical alternativeyes, I know this is why I try without js
that's not a reasonable solution in this situation
I know fetch, I try to learn many times, but something is missing, and I do not understand it
it's the understanding that php can just be called at any point in time
like an api
I'd recommend trying again and making a post in #discussions if you get stuck
in this case I cannot solve this. It is too difficult to me.
it's honestly a vital skill as a web developer, and not something you can avoid
To me this is a hobby only, so I just cancel my ideas which need databases 🙂
Thank you so much for helping to everyone
thats how you stop growing as a web developer
gotta get out of the comfy zone
yes, but I do not know anyone who can install windows on a computer. Not that who interested about programming. And I have limites where I need some help, but I cannot found.
you can make posts in #discussions if you want help learning things
mdn has examples of this
just be specific with your questions, lay out what you know, what you've tried, and how you think things work
a "can someone explain
fetch
" won't get a lot of traction, but if you put some effort into the question I'm sure someone will give it a shotif someone can ask question that means half understand. I do not undestand at all fatch/api
I cannot ask, because I do not know what I do not understand
Start with what you do, and go from there 🤷
Example I did this course: https://youtu.be/lfmg-EJ8gm4?si=WuSzGjgEk00rztYy
Bro Code
YouTube
JavaScript Full Course for free 🌐 (2024)
#javascript #tutorial #course
⭐Time Stamps⭐
#1 00:00:00 JavaScript tutorial for beginners 🌐
#2 00:12:32 Variables 📦
#3 00:25:20 Arithmetic operators ➕
#4 00:33:47 Accept user input 💬
#5 00:39:09 Type conversion 💱
#6 00:44:48 Constants 🚫
#7 00:52:30 ⭐ Counter program 🔢
#8 01:01:46 Math object 🧮
#9 01:07:23 Random number genera...
and I reached Promises, and pitch black
Promises , Fetch data from an API
you practically never write your own promises, so if that's where you got stuck, don't worry about it. Other than that, promises are just code that runs later. You tell javascript "when something happens, please run this code"
if you use
await
, then it's "wait until this happens, then run this code"
otherwise it just goes on with whatever's nextI try to use await, but no luck
something I do not understand
but I have no idea what
you can try asking more broad questions too, but be prepared to just get linked articles. If you do your due diligence and read the articles people link, you can always ask follow up questions
do not worry, it is just a hobby. I skip my ideas which need those 🙂
One more time thank you so much for everyone
glad to help!