How to load second DropDown list from Database after first DropDownList is changed

后端 未结 4 1586
遥遥无期
遥遥无期 2021-01-17 00:56

I am building a Web App. At some point a user needs to input data to a form. This form has several text fields and DropDownLists.

One of the DDLs is dep

4条回答
  •  悲哀的现实
    2021-01-17 01:55

    If the data in the second drop-down is dependent on the data in the first, then you will have to load the values of the second dropdown into a javascript object, like so:

    // Given the options in the first dropdown are: "foo", "bar", and "baz"
    var secondData = {
        foo: ['lorem', 'ipsum'],
        bar: [1,2,3],
        baz: []
    }
    

    Add a 'change' event to the first dropdown, and given the value of that dropdown, load the contents of the second dropdown with the values contained in the secondData object.

提交回复
热议问题