Skip to content
Advertisement

Write to MySQL DB from HTML page

My goal is from a Bootstrap toggle button write on MySQL DB “yes” or “no”. I know that JavaScript in client-side so I found a way (but not sure is the best) to collect variable from JavaScript and pass it to a PHP file that will write on DB. My relevant code is below, but if I try, nothing happens. I suppose that inside my JavaScript code I have to call “function saveStato”, but I cannot understand in which way.

JavaScript

Advertisement

Answer

You can define it outside of your change listener, and call it inside with

JavaScript

Or just get rid of the function altogether and just have

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement