JSFiddle - React, Tailwind, and code Playground
JavaScript
function valore()
{
var carati = 0;
var valore = 0;
var grammi = 0;
grammi = document.getElementById("grammi_ins").value;
carati = document.getElementById("carati").value;
switch (carati) {
case "24":
valore = grammi*document.getElementById("val24").value;
break;
case "18":
valore = grammi*document.getElementById("val18").value;
break;
case "14":
valore = grammi*document.getElementById("val14").value;
break;
default:
valore = 0;
}
valore =
document.getElementById("prezzo").innerHTML = Math.round(valore*100)/100 + " €";
}