ポップアップ・レベルの値、レベルの値

2701 ワード





      
 

    window.onload = function () {
        var oDemo = document.getElementById("demo");
        var oInput = document.getElementsByTagName("input")[0];
        var oDropbox = document.getElementById("dropbox");
        var aA = oDropbox.getElementsByTagName("a");
        var oClose = document.getElementsByTagName("em")[0];
        var i = 0;

        oInput.onclick = function (event) {
            oDropbox.style.display = "block";
            oDropbox.style.top = oDemo.offsetHeight + "px";
            oDropbox.style.left = oInput.offsetLeft + "px";
            oDropbox.style.width = oInput.clientWidth - 10 + "px";
            (event || window.event).cancelBubble = true;
        };

        for (i = 0; i < aA.length; i++) {
            aA[i].onclick = function (event) {
                oInput.value = this.innerHTML;
                (event || window.event).cancelBubble = true;
            };
        }

        oDropbox.onclick = function (event) {
            (event || window.event).cancelBubble = true;
        };

        document.onclick = oClose.onclick = function () {
            oDropbox.style.display = "none";
        };
    };