morpe

Arrey e For per la stampa

Jan 13th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stampa ="la frutta è:<br> \n";
  2.  
  3. var frutta = new Array();
  4.  
  5. frutta[0] = "banane";
  6. frutta[1] = "melone";
  7. frutta[3] = "cocomero";
  8. frutta[9] = "mela";
  9.  
  10. var colori = new Array("verde","rosso","", "blu");
  11.  
  12. for(var ind=0; ind<frutta.length; ind++)
  13.     {
  14.        
  15.         if(frutta[ind])
  16.             {
  17.             stampa += ind + " -> ";
  18.             stampa += frutta[ind];
  19.             stampa += "<br>\n";
  20.             }
  21.  
  22.     }
  23.  
  24. stampa +="<br>i colori sono:<br> \n";
  25.  
  26. for(var ind=0; ind<colori.length; ind++)
  27.     {
  28.        
  29.         if(frutta[ind])
  30.             {
  31.             stampa += ind + " -> ";
  32.             stampa += colori[ind];
  33.             stampa += "<br>\n";
  34.             }
  35.  
  36.     }
  37.  
  38. // ################################### nel file html ############################
  39.  
  40.     <script type="text/javascript">
  41.         document.write(stampa);
  42.     </script>
Advertisement
Add Comment
Please, Sign In to add comment