Here's the issue: you're mixing PHP and javascript.
PHP is a server-side language, and as such will only be run on the server.
Javascript is a client-side language and is run inside the browser (or on the client's computer).
Now, what you have is the form submitting to itself with an ID in the URL (as a $_GET variable). Now, when your script reloads, all that POST data will be available to it.
Now, in your javascript, you use PHP to check for the submit item. Since Javascript has no idea what $_POST is, nothing will happen. Now, if you were to pull that if() statement out of the echo statement, you'd get the alert added as you expect; however, there is a minor detail. The alert will only show up after the form is submitted for a second time.... yet the form submission reloads the page 🙁