asked on
public ActionResult GetSubClassifications(long parentID)
{
AssetManager assetManager = new AssetManager();
var list = assetManager.GetCodeValues(Domain.Enum.CodeValueType.ClientIndustrySubClassification, parentID);
ArrayList array = new ArrayList();
foreach (CodeValue item in list)
{
array.Add(new { value = item.CodeValueID, text = item.Description });
}
return Json(array);
}
$('select[name="Client.IndustryClassificationCode"]').change(function ()
{
$.ajax
({
type: 'POST',
url: '@Url.Action("GetSubClassifications", "Client")' + '?parentID=' + this.value,
contentType: 'application/json, charset=utf-8',
dataType: 'json',
success: function (responseData)
{
//alert(responseData);
var select = $('select[name="Client.IndustrySubClassificationCode"]');
var options = select.attr('options');
//clear all current options from subclass select:
$('option', select).remove();
//populate subclass select with new options:
$.each(responseData, function (index, item)
{
options[options.length] = new Option(item.text, item.value);
});
},
error: function (xhr, textStatus, errorThrown)
{
alert('Status: ' + xhr.status + '\nText: ' + textStatus + '\nError: ' + errorThrown);
}
});
});