views:

45

answers:

1

I have a dropdown that shows countries. When the user selects United States or Canada, then another drop drop will appear. Everything works with Firefox, but not with Internet Explorer.

$(document).ready(function() {
    $('.CountriesDropDown').change(changeAddressOptions);
   // alert('loaded');
    // call change event in case value was cached from reset
});

function changeAddressOptions(){
    // this is drop down
    var jsThis = $(this);
    var selectedVal = jsThis.val();

    var targetElementWrapper = jsThis.parents('li:first').siblings('.addressContentsWrapper');
    var elementToPopulate = targetElementWrapper.children('.addressContents');

    if (selectedVal == null || selectedVal == '') {
        targetElementWrapper.fadeOut();
        elementToPopulate.empty();
    }
    else {
        var loadingImage = jsThis.siblings('.loadingImage');
        loadingImage.show();
        var bindingPrefix = extractBindingPrefix(jsThis);
        if (selectedVal == 'US') {
            var elementUrl = '/AddressInfo.aspx/UsAddressInfo/?bindingPrefix=' + bindingPrefix;
        }
        else if (selectedVal == 'CA') {
        var elementUrl = '/AddressInfo.aspx/CanadaAddressInfo/?bindingPrefix=' + bindingPrefix;
        }
        else {
            var elementUrl = '/AddressInfo.aspx/InternationalAddressInfo/?bindingPrefix=' + bindingPrefix;
        }
        targetElementWrapper.hide();
        elementToPopulate.empty();
        $(elementToPopulate).load(elementUrl, countryLoadComplete);
    }
}

function countryLoadComplete() {
    var wrapper = $(this).parents('.addressContentsWrapper:first');
    $(wrapper).fadeIn('fast', hideLoadingImage);
}

function hideLoadingImage() {
    var loadingImage = $(this).siblings().find('.loadingImage');
    loadingImage.hide();
}

function extractBindingPrefix(element) {
    // hack - grab binding prefix from neighboring labe, since lastIndexOf never works;
    var bindingPrefixHolder;
    var bindingPrefix;
    bindingPrefixHolder = $(element).siblings('.bindingPrefix');
  ///  var lastPeriod = elementName.indexOf('.', 0);
   // if (lastPeriod = -1)
   //     bindingPrefix = '';
    //else {
    //    bindingPrefix = elementName.substring(0, lastPeriod);
   // }

    bindingPrefix = bindingPrefixHolder.html();
    return bindingPrefix;
}
A: 

You have to wrap you jQuery objects in $() everytime you use a jQuery function:

var jsThis = $(this);
var selectedVal = jsThis.val();

Should be

var jsThis = $(this);
var selectedVal = $(jsThis).val();

This needs to be fixed in numerous places in your script.

WeekendWarrior
This is not true.
queen3
It is still not working. This what I have now. I have made the change as you have sugested. Please keep in mind that I am new to jquery. Thanks
I am also thinking that it has something do with the timingout. there is a disscustion... http://stackoverflow.com/questions/459224/jquery-animate-and-browser-performance
I am just not that familiar with jquery.