I'm trying to execute my javascript functions, that have PHP code inside, when I click on a button but once I load the page on browser all javascript functions execute without clicking any button. When I try to press a button and execute a function nothing happens. My code is:
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width" />
    <title> LED </title>
    <script>
        function exec_vermelho(){
            <?php exec( "sudo python led.py 100 0 0" ); ?>
        }
        function exec_verde(){
            <?php exec( "sudo python led.py 0 100 0" ); ?>
        }
        function exec_azul(){
            <?php exec( "sudo python led.py 0 0 100" ); ?>
        }
        function exec_amarelo(){
            <?php exec( "sudo python led.py 100 100 0" ); ?>
        }
        function exec_ciano(){
            <?php exec( "sudo python led.py 0 100 100" ); ?>
        }
        function exec_magenta(){
            <?php exec( "sudo python led.py 100 0 100" ); ?>
        }
        function exec_branco(){
            <?php exec( "sudo python led.py 100 100 100" ); ?>
        }
    </script>
</head>
<body>
    <input type="button" name="botao_vermelho" value="Vermelho" onclick="exec_vermelho()">
    <input type="button" name="botao_verde" value="Verde" onclick="exec_verde()">
    <input type="button" name="botao_azul" value="Azul" onclick="exec_azul()">
    <input type="button" name="botao_amarelo" value="Amarelo" onclick="exec_amarelo()">
    <input type="button" name="botao_ciano" value="Ciano" onclick="exec_ciano()">
    <input type="button" name="botao_magenta" value="Magenta" onclick="exec_magenta()">
    <input type="button" name="botao_branco" value="Branco" onclick="exec_branco()">
</body>
</html>
Does anyone know why all PHP on functions execute once I load the page and then nothing happens when I click on a button? Do I need to change anything on the buttons or javascript?
Thank you.
 
     
    