I have a 2 Dropdownlistfor in html, dropdownlistfor Country and dropdownlistfor state. Im using MVC, I want to be the output like this, If I change the Selected Country, the state of the selected country will be filled in the dropdownlistfor state. Im getting the data of country and state from database, and in the table of state there is a field for countryId. Thanks for help.
here is the sample Code in Html.
<div class="fieldBlock">
<div><label>Country</label> *</div>
<div>@Html.DropDownListFor(model => model.Country.Id, Model.CountrySelectList, new { @class = "width305", @id = "ddlCountry" })</div>
@Html.HiddenFor(model => model.Country.Name) @Html.HiddenFor(model => model.Country.Abbreviation)
<div>@Html.ValidationMessageFor(model => model.Employee.StateId)</div>
</div>
<div class="fieldBlock">
<div>@Html.LabelFor(model => model.Employee.StateId, "State/Province") *</div>
<div>@Html.DropDownListFor(model => model.Employee.StateId, Model.CountryStateProvinceSelectList, new { @class = "width305" })</div>
<div>@Html.ValidationMessageFor(model => model.Employee.StateId)</div>
</div>