as the title says, I keep getting \"undefined\" when I try to get the id attribute of an element, basically what I want to do is replace an element with an input box when th
Because of the way the function is called (i.e. as a simple call to a function variable), this is the global object (for which window is an alias in browsers). Use the obj parameter instead.
Also, creating a jQuery object and the using its attr() method for obtaining an element ID is inefficient and unnecessary. Just use the element's id property, which works in all browsers.
function showHideOther(obj){
var sel = obj.options[obj.selectedIndex].value;
var ID = obj.id;
if (sel == 'other') {
$(obj).html("");
} else {
$(obj).css({'display' : 'none'});
}
}