Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
<script type="text/javascript" language="JavaScript">
function aumenta(nome, value) {
var strValoreMax = 6; //Valor massimo per ogni singolo elemento
tot_input = document.getElementById("tot");
changed_input = document.getElementById(nome);
tot = 1*tot_input.value;
changed = 1*changed_input.value;
if ((tot - value)<0) {
alert("TOtale massimo")
} else {
if (((changed + value)>=(strValoreMax+1)) || ((changed + value)<0)) {
alert("Basta")
} else {
tot_input.value = tot - value;
changed_input.value = changed + value;
}
}
}
</script>
<form name="my_form">
<input type="text" id="tot" name="tot" value="100" style="width: 40px;" disabled="disabled">
<input type="button" id="forza_minus" name="forza_minus" value="-" onclick="aumenta('forza', -1)">
<input type="text" id="forza" name="forza" value="0" style="width: 20px;" disabled="disabled">
<input type="button" id="forza_plus" name="forza_plus" value="+" onclick="aumenta('forza', 1)">
<input type="button" id="velocita_minus" name="velocita_minus" value="-" onclick="aumenta('velocita', -1)">
<input type="text" id="velocita" name="velocita" value="0" style="width: 20px;" disabled="disabled">
<input type="button" id="velocita_plus" name="velocita_plus" value="+" onclick="aumenta('velocita', 1)">
<input type="button" id="potere_minus" name="potere_minus" value="-" onclick="aumenta('potere', -1)">
<input type="text" id="potere" name="potere" value="0" style="width: 20px;" disabled="disabled">
<input type="button" id="potere_plus" name="potere_plus" value="+" onclick="aumenta('potere', 1)">
</form>
</body>
</html>
fatto