ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (±Ð¾Ç²Ä7½g)JavaScript °}¦C

[±Ð¾Ç] (±Ð¾Ç²Ä7½g)JavaScript °}¦C

°}¦C(Array)
°}¦C¬OÅܼƤ§¤ý¡I¦¹¸Ü«çÁ¿¡H¦]¬°³æ¯ÂªºÅܼƤ@¦¸¥u¯à¦s¨ú¤@µ§¸ê®Æ¡A¦Ó°}¦C«o¥i¥H¦s¨ú¦hµ§¸ê®Æ¡I²¨¥¤§¡G°}¦C¬O¤@¸sÅܼƪº¶°¦X¡C
¦pªG§Ú­Ì¦³3µ§¤£¦Pªº¸ê®Æ­n§Q¥Î³æ¯ÂªºÅܼƨӦs©ñ¡A«h§Ú­Ì¥²¶·¦bµ{¦¡¼¶¼g¤¤¨Ï¥Î3­ÓÅܼƨӤÀ§O¦s©ñ¸ê®Æ¡G
  1. X=¡¨¬P´Á¤@¡¨;
  2. Y=¡¨¬P´Á¤G¡¨;
  3. Z=¡¨¬P´Á¤T¡¨;
½Æ»s¥N½X
¦ý§Ú­Ì­Y¨Ï¥ÎJavaScript©Ò´£¨ÑªºArray()°}¦Cª«¥ó¡A«h¥i¦P®É±N¤W¨Ò¤¤¬Û¦Pªº¤Tµ§¸ê®Æ¦s©ñ¨ì°}¦CÅܼÆtest¤¤¡G
  1. test= new Array("¬P´Á¤@","¬P´Á¤G","¬P´Á¤T");
½Æ»s¥N½X
°}¦Cªº¨Ï¥Î¬O¥²¶·new«Øºc¤l«Ø¥ß¥X¤@­Ó·sªº°}¦CÅܼƤè¯à¨Ï¥Î¡I
«Ø¥ß°}¦CÅܼÆ
  1. °}¦CÅܼƦW = new Array();
½Æ»s¥N½X
½Ðª`·N¡G¤W¦C®æ¦¡¤¤Array()ª«¥óªº¡uA¡v¦r¥À¬O¤j¼g¡C

°}¦Cªº¦s¨ú
§Ú­Ì«Ø¥ß¤@­ÓÅܼư}¦C¤§«á¡A¥i¥H±N³vµ§¸ê®Æ¦s¤J°}¦C¤¤¡A¦ý¬O¥²¶·«ü©w°}¦C¤¸¯Àªº¡yµù¼Ð¡z¡A¤]´N¬O»¡°}¦CÅܼƤºªº¨C¤@µ§¸ê®Æ´N¬O¤@­Ó°}¦C¤¸¯À¡A­n¦s¨ú³o¨Ç°}¦C¤¸¯À¤ºªº¸ê®Æ¡A¥²¶·«ü©w°}¦C¤¸¯Àªº¡y½s¸¹¡z¡I¨ä¤èªk´N¬O¦b°}¦CÅܼƫá¤è¥[¤W¡¨[°}¦Cµù¼Ð]¡¨¡I
  1. test[3] = ¡§¬P´Á¥|¡¨;
½Æ»s¥N½X
©ÎªÌ¡G
  1. test[0]="xxx";
  2. test[1]="yyy";
  3. test[2]=test[0]+test[1] ;//test[2]¸ê®Æ¬°¡¦xxxyyy¡¦
½Æ»s¥N½X
§Ú­Ì¥i¥H¦b°}¦CÅܼƫإ߫á¦A±N³vµ§¸ê®Æ¦s¤J°}¦C¤¤¡G
  1. test = new Array();
  2. test[0]="xxx";
  3. test[1]="yyy";
½Æ»s¥N½X
¤]¥i¥H±N°}¦CÅܼƤºªº¸ê®Æ¦bÅܼư}¦C«Ø¥ß®É´N±N¸ê®Æª½±µ¦s©ñ¶i¥h¡A¨ä®æ¦¡¦p¤U¡G
«Ø¥ß°}¦CÅܼÆ
  1. °}¦CÅܼƦW = new Array(¸ê®Æ1,¸ê®Æ2,¡K)
½Æ»s¥N½X
¨Ò¦p¡G
  1. test= new Array("¬P´Á¤@","¬P´Á¤G","¬P´Á¤T");
½Æ»s¥N½X
·í§Ú­Ì«Ø¥ß¤@­ÓÅܼư}¦C¤§«á¡A³o­ÓÅܼư}¦Cªº¤º®e¡A¬O¥i¥H¤@¦¸¥þ³¡¿é¥X¡A¦b¸ê®Æ¶µ¤§¶¡±N·|¦³¡u¡A¡v³r¸¹¹j¶}¡G
  1. <BODY>
  2. test°}¦C¤º®e¡G
  3. <Script LANGUAGE="JavaScript">
  4. test= new Array();
  5. test[0]="¬P´Á¤é";
  6. test[1]="¬P´Á¤@";
  7. test[2]=test[0]+test[1];
  8. document.write(test);
  9. </Script>
  10. </BODY>
½Æ»s¥N½X


¹ê§@¾Ç²ß:²©ö¤ë¾ä
²{¦bªº±z¤w¸g¨ã³Æ¬Û·í¼¶¼gJavaScriptªº¥\¤O¤FËç¡I²{¦b§Ú­Ì´N§Q¥ÎHTML¼ÐÅÒ¥[¤W§Ú­Ì¥Ø«e©Ò¾Ç·|ªº°}¦CÅܼơB§PÂ_±Ô­z¡B¤é´Áª«¥ó¨Ó¼¶¼g¤@­Ó±`¦bºô¸ô¤W¬Ý¨ìªºÂ²©ö¤ë¾ä§a¡I
  1. <HTML>
  2. <HEAD>
  3. <TITLE>²©ö¤ë¾ä</TITLE>
  4. </HEAD>
  5. <BODY>

  6. <SCRIPT Language="JavaScript">
  7. day = new Date();
  8. days = day.getDay();
  9. month = day.getMonth();
  10. year=day.getYear();
  11. check = day.getYear()%4;

  12. numdays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

  13. if(check == 0){ numdays[1] = 29; }

  14. document.write("<center><table border>");

  15. //¥H¤U±Ô­z¥²¶·³s±µ¼g¦¨¤@¦æ
  16. document.write("<tr align=center><th colspan=7><font color=\"#0000ff\" size=\"2\">¤¤µØ¥Á°ê"+(year-1911)+"¦~ "+(month+1)+"¤ë</th></tr>");

  17. //¥H¤U±Ô­z¥²¶·³s±µ¼g¦¨¤@¦æ
  18. document.write("<tr align=center><th><font color=\"#ff0000\">¤é</a></th><th>¤@</th><th>¤G</th><th>¤T</th><th>¥|</th><th>¤­</th><th><font color=\"#00ff00\">¤»</a></th></tr>");  

  19. for(start = 1-days; start <= 31; start +=7);
  20. {
  21. document.write("<tr align=center>");
  22. for(i = start; i < start + 7; i++);
  23. {
  24. if((i > 0) && (i <= numdays[month]))
  25. {document.write("<td>"+ i +"</td>"); }
  26. else{ document.write("<td>&nbsp;</td>"); }
  27. }
  28. document.write("</tr>");
  29. }

  30. document.write("</table>");

  31. </SCRIPT>

  32. </BODY>
  33. </HTML>
½Æ»s¥N½X
´£¥Ü¡Gµ{¦¡½X¤¤ªº<th>¼ÐÅÒ¡A¨äÄݩʦPµ¥©ó¼Ð·Çªº<td>HTML¼ÐÅÒ¡A¤£¹L<th>¼ÐÅÒ¤ºªº¤å¦r·|Åܦ¨²ÊÅé¡I
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

        ÀR«ä¦Û¦b : ¤Hªº²´·úªø¦b«e­±¡A¥u¬Ý¨ì§O¤Hªº¯ÊÂI¡Aµ·²@¬Ý¤£¨ì¦Û¤vªº¯ÊÂI¡C
ªð¦^¦Cªí ¤W¤@¥DÃD