Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>checkbox Buttons Color Test</title>
- <script type="text/javascript">
- var mycolors = new Array();
- mycolors[0] = "red";
- mycolors[1] = "blue";
- mycolors[2] = "yellow";
- function makeList(currentArray)
- {
- var i;
- for (i=0;i<currentArray.length;i++)
- {
- document.write(currentArray[i] + "<br />");
- }
- }
- function writecheckbox(currentArray)
- {
- document.write("<form name =theform>");
- for(var i=0;i<currentArray.length;i++)
- {
- document.write('<input type="checkbox" Name=color onclick="selectcolor('+i+')" value="'+currentArray[i]+'" /> '+currentArray[i]+'<br />');
- }
- document.write("</form>");
- }
- function selectcolor(checkedcolor)
- {
- for(var i=0;i<mycolors.length;i++)
- {
- if(document.theform.color[checkedcolor].checked)
- {
- printbox.innerHTML = mycolors[checkedcolor];
- }
- }
- }
- </script>
- </head>
- <body>
- <table border="1">
- <td>
- <div id = "printbox">
- <script>
- makeList(mycolors)
- </script>
- </div>
- </td>
- </table>
- <br />
- <tr>
- <script>
- writecheckbox(mycolors);
- </script>
- <tr>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement