简体   繁体   中英

Checkbox or button inside of a form to run a task without submit?

I have a real problem, I can't get sorted out?

I have a form to look up Users and it brings back the user by id of course. Then you can look at their profile and see their email, comments and whatever. You can make little changes and click the save button and it UPDATES the record.

I have another php script that needs the $email variable from that exact user to process another script to "suspend" their billing payment? (since they are only lined by email)

I was thinking of having either a button or checkbox that basically states, Check or Press to Suspend this user (without clicking the Save on the main form) so it works independently, but still needs to grab the $email via POST or GET or $email = (isset($_POST['email']) ? $_POST['email'] : "");

Maybe an Ajax or Jquery script... Or can I do this with PHP?

I don't even know if it is doable. If I run the script on it's own, via GET, it works perfect with the errors and echo statements, but I think there is a better work around. It would be nice to just click a button or check to run a process and get a returned echo!

If button is clicked or checkbox is checked run this script and pass it a variable sort of thing??

Thanks in advance, I'm not sure where to start??

Yes use AJAX in jQUERY

$('#radio_button_id').click(function(){

$.ajax({
type: "POST",
url: "file.php",
data : "?id=id",
cache : false,
success: function(html) { $('#div_id').html(html); }
});

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM