I have an external javascript file(myscript.js) and a php file (myfile.inc). In my inc i have html code where i have a button constructed like the below
<button onclick='getvariable()'>Get Variable</button>
My functin get variable looks something like this
function getvariable(){
myVariable = 'test'
return myVariable
}
I want to be able to access myVariable in the inc file in php so i can use a function to write the results to a database. For this context writing to a db in javascript wont be allowed. I need to generate the variable from a button click in javascript and save the variable in php so i can use a function to save the result to a databse.
How can i accomplish passing this javascript variable to the inc file in php?