How can I add javascript variables into a javascript array based on what html check boxes are checked off? I would like to check boxes off and have each checked box add choice# into var final_list.
How should I id my checklists and what should I change my var final_list=[ ] to?
Here is the html for my check boxes (There are 12 in total):
<input type="checkbox" id="c1" name="c1" />
Here is the javascript:
function myFunction(){
var list1 = [ ];
var list2 = [ ];
var list3 = [ ];
var list4 = [ ];
var list5 = [ ];
var list6 = [ ];
var list7 = [ ];
var list8 = [ ];
var list9 = [ ];
var list10 = [ ];
var list11 = [ ];
var list12 = [ ];
var choice1 = list1[Math.floor(Math.random()*list1.length)];
var choice2 = list2[Math.floor(Math.random()*list2.length)];
var choice3 = list3[Math.floor(Math.random()*list3.length)];
var choice4 = list4[Math.floor(Math.random()*list4.length)];
var choice5 = list5[Math.floor(Math.random()*list5.length)];
var choice6 = list6[Math.floor(Math.random()*list6.length)];
var choice7 = list7[Math.floor(Math.random()*list7.length)];
var choice8 = list8[Math.floor(Math.random()*list8.length)];
var choice9 = list9[Math.floor(Math.random()*list9.length)];
var choice10 = list10[Math.floor(Math.random()*list10.length)];
var choice11 = list11[Math.floor(Math.random()*list11.length)];
var choice12 = list12[Math.floor(Math.random()*list12.length)];
var final_list = [ ];
var finalchoice = final_list[Math.floor(Math.random()*final_list.length)];
}