I am in a pickle right now… I have this function that gets 2 variables from a page then run a sql query after it grabs the data.
function delete(id,date){
confirmdel=confirm('Are you sure?');
if(confirmdel){
var curid = id;
var when = date;
//sql code should go here
}
else{
//don't do anything
return false;
}
}
How do I run an sql query from the function or send the data to a php file? I tried using jquery but it would just ignore it, so if I can use jquery please explain/give an example of how to use it.
JavaScript can’t deal with databases on its own, it just can tell the browser what to do and is only loaded after the server has submitted the page to the browser. So I guess you’ll have to work with AJAX. This is quite simple using jQuery:
Your process.php could look something like:
You get the idea… 😉
//EDIT:
You should probably use the jQuery UI for the dialog-box to avoid the message as described in the comments. It could be something like this: