Jquery Add Values to Select Options

后端 未结 3 969
梦如初夏
梦如初夏 2021-01-16 18:36

I have googled this option for many days but I couldn\'t find a solution.

What I want is:

  1. I have two Select Box
  2. First Select Box have Country
3条回答
  •  滥情空心
    2021-01-16 18:56

    Assumption

    • You have a script ("/getCities.php") that takes a parameter ("country") that is the ID of the country you want the cities of and outputs JSON that looks like this:

      {"Cities":
      [
          {
              "ID": 1,
              "Name": "New York"
          },
          {
              "ID": 2,
              "Name": "Los Angeles"
          }
      ]}
      

      (You can use JSONLint to validate your JSON.)

    Then maybe something along these lines:

    
    
    
    
    

提交回复
热议问题