Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/09/2012, 21:41
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Contador: incrementar valor en 100

más que un contador, sería sumar y ó restar 100 al valor inicial y el resultante, por ejemplo para 0


Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.  
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. function incrementar(){
  10. var valor = document.getElementById('cuenta').value;
  11. var valor = parseInt(valor);
  12. document.getElementById('cuenta').value = valor+100;
  13. }
  14. function reducir(){
  15. var valor = document.getElementById('cuenta').value;
  16. var valor = parseInt(valor);
  17. if (valor >= 100){
  18. document.getElementById('cuenta').value = valor-100;
  19. }
  20. }
  21. //]]>
  22. </head>
  23. <form action="#">
  24. <input type="button" value="incrementar" onclick="incrementar()"/> <input type="button" value="reducir" onclick="reducir()"/><br />
  25. <input type="text" value="0" id="cuenta" />
  26. </form>
  27. </body>
  28. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.