var el=document.getElementsByName('view[]'); for (var i=0; i < el.length; i++) { if (el[i].checked) { document.getElementsByName('total')[0].checked=true; break } }