Per non sbagliare lo metto tutto!
<?php
include("funzioni/funzioni.php");
$db = logon();
$id = 1;
$query = "select * from utenti where id='$id'";
$attivo = fetch4($db,$query);
$flg = $attivo['flg_attivo'];
//
if ($flg == 1)
{$query = "select * from pg where id='$id'";
$pg = fetch4($db,$query);
$forz = $pg['forz'];
$des = $pg['des'];
$inte = $pg['inte'];
$cos = $pg['cos'];
$exp = $pg['exp'];
} else {
$forz = 10;
$des = 10;
$inte = 10;
$cos = 10;
$exp = 100;
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<link href="style.css" rel="stylesheet" type="text/css">
<body>
</p>
<div style=position: absolute; width: 465px; height: 611px; z-index: 1; left: 10px; top: 15px id=livello1>
Razza:
<select name=razza onchange=document.modulo() size=1>
<option>Umano</option>
<option>Elfo</option>
<option>Elfo Oscuro</option>
<option>Nano</option>
</select>
Classe: <select name=classe onchange=document.modulo() size=1>
<option>Guerriero</option>
<option>Mago</option>
<option>Ladro</option>
</select></p>
<label for=forz>Forza: </label>
<input id="forz" name="forz" value="<?php echo "$forz"?>" type=text />
<button onclick="aumenta('forz','tot')" title="Aumenta valore">+</button> |
<button onclick="diminuisci('forz','tot')" title="Diminuisci valore">-</button>
</p>
<label for="inte">Intelligenza:</label>
<input id="inte" name="inte" value="<?php echo "$inte"?>" />
<button onclick="aumenta('inte','tot')" title="Aumenta valore">+</button> |
<button onclick="diminuisci('inte','tot')" title="Diminuisci valore">-</button>
</p>
<label for="des">Destrezza:</label>
<input id="des" name="des" value="<?php echo "$des"?>" />
<button onclick="aumenta('des','tot')" title="Aumenta valore">+</button> |
<button onclick="diminuisci('des','tot')" title="Diminuisci valore">-</button>
</p>
<label for="cos">Costituzione:</label>
<input id="cos" name="cos" value="<?php echo "$cos"?>" />
<button onclick="aumenta('cos','tot')" title="Aumenta valore">+</button> |
<button onclick="diminuisci('cos','tot')" title="Diminuisci valore">-</button>
</p>
Punti rimanenti: <input id="tot" name="tot" value="<?php echo "$exp"?>"> </p>
// **************** QUESTO È IL FORM ********
<form action='creapgins.php' method='post' ID="Form1">
// ****************************************
<input name="entra" value="Entra" type="submit" style="font-family: Book Antiqua; font-weight:700" ID="Submit1">
</form>
</div>
</body>
<script language=javascript type=text/javascript>
function aumenta(elemento,tot)
{
var campo = document.getElementById(elemento);
var valore = campo.value;
var camp = document.getElementById(tot);
var valore2 = camp.value;
valore2 = valore2 - valore;
if (valore2 <= 0) {window.alert('Non hai abbastanza punti!!!'); return}
valore++;
campo.value = valore;
camp.value = valore2;
}
function diminuisci(elemento,tot)
{
var campo = document.getElementById(elemento);
var valore = campo.value;
var camp = document.getElementById(tot);
var valore2 = camp.value;
tot = (1*valore2 + 1*valore)- 1;
valore--;
if (valore <= 0) {window.alert('Non puoi avere meno di 1!!!'); return}
campo.value = valore;
camp.value = tot;
}
</script>
</html>

Rispondi quotando