﻿function bindDropDownList(allOptions, associatedDropDownList, targetDropDownList) {
    var chosenkey = $("#" + associatedDropDownList).val();
    var option;
    var output = [];

    targetDropDownList = "#" + targetDropDownList;
    $(targetDropDownList).empty();
    for (var i = 0; i < allOptions.length; i++) {
        option = allOptions[i];
        if (option.key == chosenkey) {
            output[i] = '<option title="' + option.text + '" value="' + option.value + '">' + MakeShortText(option.text, 95) + '</option>';
        }
    }
    
    $(targetDropDownList).append(output.join(''));
}
function MakeShortText(text, characterCount) {
    if (text.length >= characterCount) {
        return text.substr(0, characterCount) + " ...";
    }
    return text;
}
