Dear All,
I want to set value of contact information accordingly I have a ddl, once I select perticular item from ddl then I want set rest of all the field of contact information using javascript.
I am not able to find ddl's selected items value how I can find it using javascript my code is below.
even is there any great way to achieve this kind of scenario then plz let me know.
my ddl is here..
@Html.DropDownListFor(model => model.leadDetailModels.Id, new SelectList(Model.contactNames, "Id", "Name"), "-Select ContactName-", new {id = "ddlContactNames", @style = "width: 310px;height : 30px" })
now this model=>model.leadDetailModel.Id is being set but I am not able to find this value intl javascript.
my javascript code is like here...
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$(function () {
$("select#ddlContactNames").change(function () {
$("#txtContactName").val(@Html.Raw(Json.Encode(@Model.contactNames[model.leadDetailModels.Id].Name)));
$("#txtContactPhone").val(@Html.Raw(Json.Encode(@Model.contactNames[model.leadDetailModels.Id].Name)));
$("#txtContactOtherPhone").val(@Html.Raw(Json.Encode(@Model.contactNames[model.leadDetailModels.Id].Name)));
$("#txtContactEmail").val(@Html.Raw(Json.Encode(@Model.contactNames[model.leadDetailModels.Id].Name)));
$("#txtContactArea").val(@Html.Raw(Json.Encode(@Model.contactNames[model.leadDetailModels.Id].Name)));
$("#txtContactComments").val(@Html.Raw(Json.Encode(@Model.contactNames[model.leadDetailModels.Id].Name)));
});
});
</script>
}
above bold value of "mode.leadDetailModels.Id" is set null so I am getting exception here...
how I can resolve this..?
thank you..