tags:

views:

29

answers:

3

Hi, i wish to grab a load of elements, check if their id contains 'other' or 'Other' and for those, set the display to none. This is what i have:

function Hide(div){
    var list;
    var i;
    list = document.getElementById(div).getElementsByTagName("input")
    for(i=0; i<list.length;i++){
        if(list[i].id.toString().indexOf("Other") != -1 || list[i].id.toString().indexOf("other") != -1){
            list[i].id.setAttribute("Style.display","none");
        }
    }
}

but .setAttribute... doesnt work and nor did .Style.display = "none"

+1  A: 

Adjust the style property of the element not the string containing the id!

list[i].style.display
David Dorward
+1  A: 

You can't use style.display, because 'display' is a property of the style Object. You should use:

list[i].style.display = 'none'
KooiInc
A: 

Try list[i].style.display, lower case, set attribute to object itselft

Bang Dao