In javascript, error says 'is null or not an object'. When trying to use .change() code to hide form

Posted by codemonkey613 on Stack Overflow See other posts from Stack Overflow or by codemonkey613
Published on 2010-03-13T21:05:20Z Indexed on 2010/03/13 21:15 UTC
Read the original article Hit count: 472

Filed under:

I'm getting a javascript error.

URL: http://bit.ly/dfjvmT

It has to do with this section of code:

/*
 * Activate jQuery
 */
$(document).ready(function() {          

/*
 * Show hidden field when 'Other' selected from dropdown
 */
$.listHidden = { 
    '6' : $('.referrer_other')
};
$('#referrer_select').change(function() { 
    // hide all
    $.each($.listHidden, function() { 
        this.hide(); 
    });
    // show current
    $.listHidden[$(this).val()].slideDown(250);
}).change();    

});

The code works like this. The form has a dropdown asking "How did you find us?" If the user selects 'other', which is an <option> with value=6, a text input field .referrer_other becomes visible.

Javascript is currently reporting that: '$.listHidden[...] is null or not an object'. It's an error that appears in IE. I found this code on the internet somewhere. Is there a way to fix it, or should I look for something else?

Thanks

© Stack Overflow or respective owner

Related posts about jQuery