Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
C#
@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...
C#
@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..
Posted
Comments
Jameel VM 17-Jun-13 1:34am    
what is the exception?
Jitendra.Jadav 19-Jun-13 6:45am    
[model.leadDetailModels.Id] this I want selecte ID and this is I am not able to get it is not giving me error but the selection is not change...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900