Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
How to get value from combo box? Here is the following code. PLease anyone can help. Many Thanks in advance
posted

 @using (Html.BeginForm("SaveCrossProjectPrice", "CspModule", FormMethod.Post, new {id = "validationForm"}))

    {

        <fieldset>

        <div id="layout" style="width: 100%; height: 485px; display: block">

 

            <div id="crossprojectpriceGridDiv" class="left" style="width :100%">

                <table>

                    <tr>

                        <td><h4> Customer</h4></td>

                        <td>

                            @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.CustomerId)

                          .ID("customerCombo")

                          .Width("200px")

                          .DataSource(Model.Customers)

                          .ValueKey("Id")

                          .TextKey("CustomerName")

                          .NullText("Select a Customer")

                          .ValidatorOptions(options => options.Required(true))

                          .DataBind()

                          .Render()

                            )

                            @Html.HiddenFor(m => m.ComponentSalesPrice.CustomerId, new { @id = "CustomerId" })

                        </td>

                    </tr>

                    <tr>

        <td>

            <h4>Component</h4>

        </td>

                        <td>

 

                            @(Html.Infragistics().ComboFor(m=>m.ComponentSalesPrice.ComponentId)

                          .ID("componentCombo")

                          .Width("200px")

                          .DataSource(Model.Components)

                          .ValueKey("Id")

                          .TextKey("ComponentId")

                          .NullText("Select a Component")

                          .ValidatorOptions(options => options.Required(true))

                          .DataBind()

                          .Render()

                          )

                            @Html.HiddenFor(m => m.ComponentSalesPrice.ComponentId, new { @id = "ComponentId" })

                        </td></tr>

                    <tr>

                    <td>

                        <h4>Effective Start Date </h4>

                    </td>

                    <td>

    @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveStartDate)

                          .ID("EffectiveStartDate")

                          .Width(205)

                         .MaxLength(4)

                          .NullText("Enter an Effective Start Date")

                          .ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true))

                          .Required(true)

                          .Render()

    )

</td></tr>

                        <tr>

                            <td><h4> Effective End Date</h4></td>

                            <td>

                                @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveEndDate)

                          .ID("EffectiveEndDate")

                          .Width(205)

                          .MaxLength(4)

                          .NullText("Enter an Effective End Date")

                          .ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true))

                          .Required(true)

                          .Render()

                                )

                            </td>

                        </tr>

 

                    <tr><td>

                            <h4>Event</h4>

                        </td>

                   

                        <td>

                            @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.EventId)

                          .ID("eventCombo")

                          .Width("200px")

                          .DataSource(Model.Events)

                          .ValueKey("Id")

                          .TextKey("EventDescription")

                          .NullText("Select an event")

                          .ValidatorOptions(options => options.Required(true))

                          .DataBind()

                          .Render()

                        )

                        @Html.HiddenFor(m => m.ComponentSalesPrice.EventId, new { @id = "Id" })

                    </td>

                        </tr>

                        <tr><td>

    <h4>Supplier</h4>

</td>

                            <td>

                                @(Html.Infragistics().ComboFor(m => m.Supplier.SupplierName)

                          .ID("SupplierCombo")

                          .Width("200px")

                          .DataSource(Model.Suppliers)

                          .ValueKey("Id")

                          .TextKey("SupplierName")

                          .NullText("Select a Supplier")

                          .ValidatorOptions(options => options.Required(true))

                          .DataBind()

                          .Render()

                            )

                            @Html.HiddenFor(m => m.Supplier.SupplierName, new { @id = "Id" })

                        </td>

                        </tr>

                        <tr><td>

    <h4>Currency</h4>

</td>

                            <td>

                                @(Html.Infragistics().ComboFor(m => m.Currency.CurrencyCode)

                          .ID("CurrencyCombo")

                          .Width("200px")

                          .DataSource(Model.Currencies)

                          .ValueKey("Id")

                          .TextKey("CurrencyCode")

                          .NullText("Select a Currency")

                          .ValidatorOptions(options => options.Required(true))

                          .DataBind()

                          .Render()

                                )

                                @Html.HiddenFor(m => m.Currency.CurrencyCode, new { @id = "Id" })

                            </td></tr>

                        <tr><td>

    <h4>New BasePrice</h4>

</td>

                            <td>

                                @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.BasePriceExcludingIndexedMaterial)

                          .ID("NewBasePrice")

                          .Width(205)

                          .MaxLength(4)

                          .NullText("Enter a new base price")

                          .ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true))

                          .Required(true)

                          .Render()

                                )

                            </td></tr>

                    <tr>

                        <td>

                            <h4>New Calculated SellingPrice</h4>

                        </td>

                        <td>

                            @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.SellingPrice).ReadOnly(true)

                          .ID("SellingPrice")

                          .Width(205)

                          .MaxLength(4)

                          .Render()

                            )

                    </td></tr>

                    <tr>

                        <td>

                            <h4>New Selling Price Override</h4>

                        </td>

                        <td>

                            @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.SellingPriceOverride)

                                  .ID("SellingPriceOverride")

                                  .Width(205)

                                  .MaxLength(4)

                                  .Render()

                                  )

                        </td></tr>

        <tr><td>&nbsp;</td>

                    <td>

    <input type="button" id="AmendPrice" class="button-style" value="Amend Price" />

</td>

        </tr><tr>&nbsp;</tr>

</table>

            </div>

           

                </div>

        </fieldset>

    }

        }

<script>

   

    $( function() {

        $('#customerCombo').change(function() {

            var selectedcustomer = $(this).val();

            var componentCombo = $('#componentCombo');

            $.ajax({

                cache: false,

                type: "POST",

                url: "@Url.Action("GetComponentsbyCustomerId", "CspModule")",

                contentType: 'application/json; charset=utf-8',

                dataType: 'json',

                data: {

                    "customerId": selectedcustomer

                },

                success: function (data) {

                    componentCombo.html('');

                   $.each(data, function(id, option) {

                       componentCombo.append($('<option></option>'.val(option.componentId).html(option.componentId)));

                       });

                   

                },

                error: function(xhr, ajaxoptions, thrownError) {

                    alert('failed to retrieve components');

                   

                }

            });

        });

 

    });

    </script>