I have a list of recipients in the drop-down list on my form. I would like to populate another drop-down menu based on the selected recipient drop-down list item, without email messages and all that.
So, I created a method in my controller that does the work:
private JsonResult GetCategories(int payeeId)
{
List<CategoryDto> cats = Services.CategoryServices.GetCategoriesByPayeeId(payeeId);
List<SelectListItem> items = new List<SelectListItem>();
foreach(var cat in cats)
{
items.Add(new SelectListItem {Text = cat.Description, Value = cat.CategoryId.ToString()});
}
return Json(items);
}
Now I'm not sure what to add in my opinion to make this work.
At the moment, all I have is:
<% using (Html.BeginForm())
{%>
<p>
<%=Html.DropDownList("SelectedAccountId", Model.Accounts, "Select One..", null) %>
</p>
<p>
<%=Html.DropDownList("SelectedPayeeId", Model.Payees, "Select One...", null) %>
</p>
<input type="submit" value="Save" />
<%
}%>
they fill out in order ... so when the user selects the SelectedPayeeId drop-down list, he must then populate a new (not yet created?) drop-down list that contains categories based on SelectedPayeeId.
, , JQuery ( JQuery.. , ), Payee onChange? , . , , , ?