I made a function in jQuery to edit database information based on ID from a specific table.
clickme(id);
That function was called in the onclick event but it seems that's a bad pratice. My code to call the function was created in PHP so it lists automatically the ID in the function. For example, it fetches the database and list all ID's available, creating automatically a link based on ID:
<button ... onclick='clickme(1)'...</button>
<button ... onclick='clickme(2)'...</button>
<button ... onclick='clickme(3)'...</button>
Since it's a bad pratice, how can I make this same working method without using the onclick method? The objetive is using something like sweetalert to:
Click the button that contains the id and call the function
Show a sweetalert to user confirm the action in the id X
Confirm and call the function
Show another sweetalert to show OK or NOK
Anyone can help me in this? It's working with the onclick method, but I'd rather prefer to user another method, but I don't know how can I call the function with the "ID" I need too without this method. Thanks.