milardovich

Fix en función de Javascript

Apr 9th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>pruebas javascript</title>
  6. </head>
  7.  
  8. <body>
  9. <script>
  10. var imagenes = new Array();
  11.     imagenes[0] = "001.jpg";
  12.     imagenes[1] = "002.jpg";
  13.     imagenes[2] = "003.jpg";
  14.     imagenes[3] = "004.jpg";
  15.     imagenes[4] = "005.jpg";
  16.     imagenes[5] = "006.jpg";
  17.    
  18.     indice=0;
  19.    
  20. function mas(){
  21.     indice+=1;
  22.     if(indice>5){
  23.         indice=0;
  24.         }
  25.     document.images["imagen"].src = imagenes[indice];
  26.     alert("test");
  27. }
  28. function menos(){
  29.     indice-=1;
  30.     if (indice<0){
  31.         indice=5;
  32.     }
  33.     document.images["imagen"].src=imagenes[indice];
  34. }
  35. </script>
  36. <table border="0">
  37.     <tr>
  38.         <td colspan="2">
  39.         <img src="001.jpg" name="imagen">
  40.         </td>
  41.     </tr>
  42.     <tr>
  43.         <td>
  44.             <button onclick="menos();">-</button>
  45.         </td>
  46.         <td>
  47.             <button onclick="mas();">+</button>
  48.         </td>
  49.      </tr>
  50.  </table>
  51.  
  52.  
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment