﻿/* CascadingDropDownList.js */

function bindDropDownList(e, targetDropDownList) {
	var key = this.value;
	var allOptions = targetDropDownList.allOptions;
	var option;
	var newOption;
	targetDropDownList.options.length = 0;

	
	for (var i = 0; i < allOptions.length; i++) {
		option = allOptions[i];
		// added some code to only get the key if the value has been made from the id$name
		var keyDollarIndex = key.indexOf("$");
		if (keyDollarIndex != -1) {
			key = key.substr(0, keyDollarIndex);
		}
		if (option.key == key) {
			newOption = new Option(option.text, option.value);
			targetDropDownList.options.add(newOption);
		}
	}
}