jsp checkbox不错的应用

<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>

  

posted on 2010-04-12 14:10  Java码界探秘  阅读(195)  评论(0编辑  收藏  举报

导航