All pastes #620034 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-15 04:49 UTC
rendered paste body
THE BELOW IS A SNIPPET OF MY JAVASCRIPT CODE == NOTICE THERE ARE 2 window.onload FUNCTIONS THAT I NEED TO USE. HOW CAN I COMBINE MULTIPLE window.onload FUNCTIONS LIKE THE ONES BELOW (THEY ARE VERY VERY SIMILAR IN FUNCTION, THEY JUST UNHIDE DIFFERENT <tr>




<script type="text/javascript">

window.onload=function(){
var sel = document.getElementById("referredby");
sel.onchange=referralchoice;
hideEl(document.getElementById("advertQ1"));
hideEl(document.getElementById("rbQ1"));
}

window.onload=function(){
var sel = document.getElementById("previousclan");
sel.onchange=showit;
hideE2(document.getElementById("prevclanQ1"));
}

function referralchoice() {
            var o = this.options[this.selectedIndex].value;
            var trShow;
            var trHide;
            switch (o) {
                case "OTHER REFERRAL":
                        showEl(document.getElementById("rbQ1"));
                        hideEl(document.getElementById("advertQ1"));
                        break;
                case "ADVERTISEMENT":
                        showEl(document.getElementById("advertQ1"));
                        hideEl(document.getElementById("rbQ1"));
                        break;
                default:
                        hideEl(document.getElementById("advertQ1"));
                        hideEl(document.getElementById("rbQ1"));
                        break;
        }
}

function showEl(el) {
        if (document.all) {
        el.style.display="block";
        } else {
        el.style.display="table-row";
}
}

function hideEl(el) { 
            el.style.display="none";
}

function render(c, t) {
            document.getElementById(t).style.display="none";                        
                if(document.all) {
                if (c.checked)
                    document.getElementById(t).style.display="block";
                } else {
                if (c.checked)
                    document.getElementById(t).style.display="table-row";
        }
}

function showE2(el) {
        if (document.all) {
        el.style.display="block";
        } else {
        el.style.display="table-row";
}
}

function hideE2(el) {
            el.style.display="none";
}

function showit() {
            var o = this.options[this.selectedIndex].value;
            var trShow;
            var trHide;
            switch (o) {
                case "Yes":
                        showE2(document.getElementById("prevclanQ1"));
                        break;
                default:
                        hideE2(document.getElementById("prevclanQ1"));
                        break;
        }
}

</script>