Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two drop down lists
HTML
<td width="75%">
                                    @(Html.Kendo().DropDownList()
                                        .Name("ddlGrade")
                                        .HtmlAttributes(new { style = "width: 250px", @class = "editor-dropdownlist" })
                                        .OptionLabel("Select Grade...")
                                        .DataSource(
                                            dataSource =>
                                            {
                                                dataSource.Read(read => read.Action("ListAttributesBySystemID", "CatalogAttributeType", new { systemID = 16 }));
                                                dataSource.Events(events => events.Change("gradeDataSourceChange"));
                                            }
                                        )
                                        .DataTextField("Title")
                                        .DataValueField("ID")
                                        .Events(events => { events.Change("saveGradeAttribute"); })
                                    )
                                </td>



and
HTML
@(Html.Kendo().DropDownList()
                                        .Name("ddlCoinFinish")
                        .HtmlAttributes(new { @class = "editor-dropdownlist" })
                                .OptionLabel("Select...")
                        .DataSource(dataSource =>
                        {
                            dataSource.Read(read => read.Action("ListAttributesBySystemID", "CatalogAttributeType", new { systemID = 46 }));
                            dataSource.Events(events => events.Change("ddlCoinFinishDataSourceChange"));
                        }
                        )
                        .DataTextField("Title")
                        .DataValueField("ID")
                        .Events(events => { events.Change("ddlCoinFinishChange"); })
                    )
                    </td>




with value populating from the database

I want to change the value of the CoinFinish drop down list when changing the grade drop down list.

I have created this java script code
JavaScript
$("#ddlGrade").change(function () {

      if (value == 2279) {
          $('#ddlCoinFinish').val(4393).attr("selected", "selected").change();
          alert("You have Selectedddddd  :: " + $("#ddlGrade").val());
          alert("You have ddlCoinFinish  :: " + $("#ddlCoinFinish").val());
      }
  });



And the second alert box showing the changed (New) value. But there is no change in the UI of the CoinFinish Ddl. Can you please help me.
Thanks In advance.
Posted
Comments
Peter Leow 22-Apr-15 7:09am    
Do you understand the jQuery code? What is 'value' in 'value==2279'? You have hard-coded some values. It just didn't make sense.
Baiju christadima 22-Apr-15 7:41am    
The 2279 is the value for an option in the drop down list(ddlgrade)

1 solution

You should learn jQuery[^] to understand how to construct it.
 
Share this answer
 

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