multiple buttons on a form

前端 未结 6 784
遥遥无期
遥遥无期 2020-12-06 02:28

I have a clear button that I want to tie into some php coding. how do I detect if the clear button is pressed. When the user press clear, i\'m going to have it update a sql

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 03:02

    You can bind an ajax event to it being clicked. If you're using jQuery, you can bind the ajax() function to its click event. The ajax function allows for easy passing of variables, error checking, etc.

    You'll ajax call a php file, let's call it reset_ajax.php, which will make the query.

    The other option is to keep track of the reset button being clicked with a hidden input that's updated every time its clicked, and then you can make the query on the backend upon form submission.

    Up to you which method you want to use. The first one has the advantage of working even if they don't submit the form.

提交回复
热议问题