Look at the source code of the page - I think you'll find that those echo statements are working.
All PHP code is executed before the page is even sent to the user's browser. You can't execute PHP from within Javascript since PHP is a server-side language (meaning it is parsed and executed by the server before sending its output to the client) while Javascript is a client-side language.