clear array and text box with javascript i have the fallowing code done already

Each time a checkbox is checked, the below function will be called. My problem is that I need another function which should clear all the data available here.Let me explain my problem first:The concept of the program is to update the text box with the checkbox value - if two check boxes are checked, then the text box will have two values in it and so on.I need a function to clear the data on the check box so that when I click the 3rd check box it needs to show only the 3rd checkbox's value by removing the first and second from the text area. This should all happen without reloading the page\[code\]<script> function chkcontrol(j){ var textbox = document.getElementById("list"); var textbox1 = document.getElementById("val_id"); var values = []; var val_id=[]; if(document.getElementById(1).checked) { values.push('A1'); val_id.push('1'); } if(document.getElementById(2).checked) { values.push('A2'); val_id.push('2'); } if(document.getElementById(3).checked) { values.push("A3"); val_id.push('3'); } if(document.getElementById(4).checked) { values.push("A4"); val_id.push('4'); } if(document.getElementById(5).checked) { values.push("A5"); val_id.push('5'); } if(document.getElementById(6).checked) { values.push("A6"); val_id.push('6'); } textbox.value = http://stackoverflow.com/questions/15824165/values.join(","); textbox1.value = http://stackoverflow.com/questions/15824165/val_id.join(","); } function removeAll(){ }</script><input id="list" type="text" name="list"><input id="val_id" type="text" name="val_id"><input type="checkbox" name="ckb" value="http://stackoverflow.com/questions/15824165/A1" id="1" onclick='chkcontrol(0)';><label for="1"></label><input type="checkbox" name="ckb" value="http://stackoverflow.com/questions/15824165/A2" id="2" onclick='chkcontrol(0)';><label for="2"></label><input type="checkbox" name="ckb" value="http://stackoverflow.com/questions/15824165/A3" id="3" onclick='chkcontrol(0)';><label for="3"></label>\[/code\]
 
Top