home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 July / www_07_1999.iso / prez / amiga / KidHTML1_25.lha / KidHTML1.25 / Script / colortable.js < prev    next >
Text File  |  1998-08-25  |  3KB  |  130 lines

  1. <!-- TWO STEPS TO INSTALL COLOR TABLE:
  2.  
  3.    1.  Paste the designated script into the HEAD of your HTML document
  4.    2.  Add the code into the BODY of your HTML document  -->
  5.     
  6. <!-- STEP ONE:  Paste this script into the HEAD of your HTML document -->
  7.  
  8. <HEAD>
  9.  
  10. <SCRIPT LANGUAGE="JavaScript">
  11.  
  12. <!-- This script and many more are available online from -->
  13. <!-- The JavaScript Source!! http://javascriptsource.com -->
  14.  
  15. <!-- Begin
  16. function changeBackground(hexNumber) {
  17. document.bgColor=hexNumber
  18. }
  19. prefix="#"
  20. rnum1=0
  21. bnum1=0
  22. gnum1=0
  23. rnum2=0
  24. bnum2=0
  25. gnum2=0
  26. hexNumber2="#000000";
  27. rcount=0;
  28. bcount=0;
  29. gcount=0;
  30. function num2hex(num) {
  31. if (num==15) return "f";
  32. else if (num==14) return "e";
  33. else if (num==13) return "d";
  34. else if (num==12) return "c";
  35. else if (num==11) return "b";
  36. else if (num==10) return "a";
  37. else if (num==9) return "9";
  38. else if (num==8) return "8";
  39. else if (num==7) return "7";
  40. else if (num==6) return "6";
  41. else if (num==5) return "5";
  42. else if (num==4) return "4";
  43. else if (num==3) return "3";
  44. else if (num==2) return "2";
  45. else if (num==1) return "1";
  46. else return "0";
  47. }
  48. function changeBackground2(number) {
  49. if(number == 1) {
  50. rnum1=rcount%16;
  51. if (rcount <15) {
  52. rcount=rcount+1;
  53.   }
  54. }
  55. if(number == 2) {
  56. gnum1=gcount%16;
  57. if (gcount <15) {
  58. gcount=gcount+1;
  59.   }
  60. }
  61. if(number == 3) {
  62. bnum1=bcount%16;
  63. if (bcount <15) {
  64. bcount=bcount+1;
  65.   }
  66. }
  67. if(number == 4) {
  68. rnum1=rcount%16;
  69. if (rcount > 0) {
  70. rcount=rcount-1;
  71.   }
  72. }
  73. if(number == 5) {
  74. gnum1=gcount%16;
  75. if (gcount > 0) {
  76. gcount=gcount-1;
  77.   }
  78. }
  79. if(number == 6) {
  80. bnum1=bcount%16;
  81. if (bcount > 0) {
  82. bcount=bcount-1;
  83.   }
  84.  }
  85. hexNumber2 = prefix+num2hex(rnum1)+num2hex(rnum2)+num2hex(gnum1)+num2hex(gnum2)+num2hex(bnum1)+num2hex(bnum2);
  86.   document.bgColor=hexNumber2
  87. }
  88. // End -->
  89. </SCRIPT>
  90.  
  91. <!-- STEP TWO:  Add this code to the BODY of your HTML document  -->
  92.  
  93. <BODY>
  94.  
  95. <CENTER>
  96. <FORM METHOD="POST" NAME="background">
  97. <TABLE WIDTH=350 BORDER="3" CELLPADDING="3">
  98. <TR>
  99. <TD Align=center><INPUT TYPE="button" VALUE="Red" ONCLICK="changeBackground('#FF0000')"></TD>
  100. <TD Align=center><INPUT TYPE="button" VALUE="Green" ONCLICK="changeBackground('#00FF00')"></TD>
  101. <TD Align=center><INPUT TYPE="button" VALUE="Blue" ONCLICK="changeBackground('#0000FF')"></TD>
  102. <TD Align=center><INPUT TYPE="button" VALUE="White" ONCLICK="changeBackground('#FFFFFF')"></TD>
  103. <TD Align=center><INPUT TYPE="button" VALUE="Black" ONCLICK="changeBackground('#000000')"></TD>
  104. <TD Align=center><INPUT TYPE="button" VALUE="Grey" ONCLICK="changeBackground('#C0C0C0')"></TD>
  105. </TR>
  106. </TABLE>
  107. <TABLE WIDTH=350 BORDER="3" CELLPADDING="3">
  108. <TR><TD><center>Variable Background Color Changer</center></TD>
  109. </TR>
  110. </TABLE>
  111. <TABLE WIDTH=350 BORDER="3" CELLPADDING="3">
  112. <TR>
  113. <TD Align=center><INPUT TYPE="button" VALUE="+ Red" ONCLICK="changeBackground2(1)"><P>
  114. <INPUT TYPE="button" VALUE="- Red" ONCLICK="changeBackground2(4)"></TD>
  115. <TD Align=center><INPUT TYPE="button" VALUE="+ Green" ONCLICK="changeBackground2(2)"><P>
  116. <INPUT TYPE="button" VALUE="- Green" ONCLICK="changeBackground2(5)"></TD>
  117. <TD Align=center><INPUT TYPE="button" VALUE="+ Blue" ONCLICK="changeBackground2(3)"><P>
  118. <INPUT TYPE="button" VALUE="- Blue" ONCLICK="changeBackground2(6)"></TD>
  119. </TR>
  120. </TABLE>
  121. <TABLE WIDTH=350 BORDER="3" CELLPADDING="3">
  122. <TR>
  123. <TD><center>Keep pressing buttons to change color<BR>
  124. (The color will start as black)</center></TD>
  125. </TR>
  126. </TABLE>
  127. </FORM>
  128. </CENTER>
  129. <!-- Script Size:  3.44 KB  -->
  130.