Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>checkbox Buttons Color Test</title>
  4.  
  5. <script type="text/javascript">
  6.  
  7. var mycolors = new Array();
  8. mycolors[0] = "red";
  9. mycolors[1] = "blue";
  10. mycolors[2] = "yellow";
  11.  
  12.  
  13. function makeList(currentArray)
  14. {
  15. var i;
  16.  
  17. for (i=0;i<currentArray.length;i++)
  18. {
  19. document.write(currentArray[i] + "<br />");
  20. }
  21. }
  22.  
  23. function writecheckbox(currentArray)
  24. {
  25. document.write("<form name =theform>");
  26. for(var i=0;i<currentArray.length;i++)
  27. {
  28. document.write('<input type="checkbox" Name=color onclick="selectcolor('+i+')" value="'+currentArray[i]+'" /> '+currentArray[i]+'<br />');
  29. }
  30. document.write("</form>");
  31. }
  32.  
  33. function selectcolor(checkedcolor)
  34. {
  35. for(var i=0;i<mycolors.length;i++)
  36. {
  37.  
  38. if(document.theform.color[checkedcolor].checked)
  39. {
  40. printbox.innerHTML = mycolors[checkedcolor];
  41. }
  42.  
  43. }
  44. }
  45.  
  46. </script>
  47. </head>
  48.  
  49.  
  50.  
  51. <body>
  52.  
  53. <table border="1">
  54. <td>
  55. <div id = "printbox">
  56. <script>
  57. makeList(mycolors)
  58. </script>
  59. </div>
  60. </td>
  61. </table>
  62.  
  63.  
  64. <br />
  65.  
  66.  
  67. <tr>
  68.  
  69. <script>
  70. writecheckbox(mycolors);
  71. </script>
  72. <tr>
  73.  
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement