increment disminir
by femfoyou
HTML
<form name="caca">
<input type="button" onClick="incrementar()" value="aumentar">
<input type="button" onClick="decrementar()" value="disminuir">
<label>
<input name="muchacaca" type="text" >
</label>
</form>
<button id="button1" onclick="changeFontSize(this)">a+</button>
<button id="button2" onclick="changeFontSize(this)">a-</button>
<h1 id="numero">0</h1>
JavaScript
var contador=0;
function incrementar() {
if(contador==3)
alert('Maximo permitido alcanzado: 3');
else {
document.caca.muchacaca.value= contador++;
}
}
function decrementar() {
if(contador==0)
alert('Minimo permitido alcanzado: 0');
else {document.caca.muchacaca.value= contador--;}
}
var fontSize = 0;
function changeFontSize(target) {
var numer = document.getElementById('numero');
if (target == document.getElementById("button1")) { fontSize += 1; }
else if (target == document.getElementById("button2")) { fontSize -= 1;}
numer.innerHTML = fontSize;
}