So basically, I'm coding a page that will have multiple divs (depending on the result of an SQL request, but that doesn't really matter) that all got the same structure (some text and two buttons), I need to pass a variable into this div to get it later.
So I had the idea of putting that variable into the IDs of both buttons (using php), which works fine.
type=\"submit\" id=".$id_note." name=\"delete\" value=\"Delete\"> //id_note=my variable
I know that it may not sound very clear, but that's the best I can do.Bind events to each button and then get the id attribute from the clicked button
$('button').click(function () {
var id = $(this).attr('id');
});
If you have other buttons on your page, you should add a class to the buttons and then bind the event to that class instead.
Edit: Read too quickly.
You cannot retrieve the id of the button in your PHP when the form has been submitted. It only processes the input elements with a name, in to an associative array you can access the value the input field had. e.g $_POST['form_name']
So as in the comments, best solution would be to use a hidden field that contains the id
<input type="hidden" name="id_note" value="<?php echo $id_note; ?>">
And then when submitted
$_POST['id_note']; // --> id_note value