Ecco due esempi con vanilla js e con jquery
codice:<html> <head> <script language="JavaScript" src="https://code.jquery.com/jquery-3.6.1.min.js"></script> <script language="Javascript" type="text/javascript"> //jquery $(document).ready(function() { $("#calcjq").click(function(){ netto_struttura = $("#netto_struttura").val(); netto_volo = $("#netto_volo").val(); $("#totale").val( parseInt(netto_struttura) + parseInt(netto_volo) ); }); }); //js vanilla window.onload = function() { document.getElementById("calcjs").onclick = function(){ netto_struttura = document.getElementById("netto_struttura").value; netto_volo = document.getElementById("netto_volo").value; document.getElementById("totale").value = parseInt(netto_struttura) + parseInt(netto_volo); }; }; </script> </head> <body style="margin-top: 0cm; margin-left: 0cm;" title="Clicca per stampare"> Campo netto_struttura:<input type="text" id="netto_struttura" value=""><br> Campo netto_volo:<input type="text" id="netto_volo" value=""><br><br> <input type="button" id="calcjs" value="calcola js"><br> <input type="button" id="calcjq" value="calcola jquery"><br> Totale:<input type="text" id="totale" value=""> </body> </html>