<input type="checkbox" name="a" value="1" /> <input type="checkbox" name="a" value="2" /> <input type="checkbox" name="a" value="3" /> <input type="checkbox" name="a" value="4" /> </div> <script type="text/JAVAscript"> function docheck(stringToShow) { stringToShowArray = stringToShow.splIT(","); var domArray = document.getElementsByName("a"); for (var i = 0; i < domArray.length; i++) { if (isInArray(domArray[i].value, stringToShowArray)) { domArray[i].checked = true; } } } function isInArray(number, numberArray) { for (var i = 0; i < numberArray.length; i++) { if (number == numberArray[i]) { return true; } } return false; } docheck("1,2,4"); </script>