using jquery how do I filter a dropdown field based on value selected from another dropdown field

前端 未结 3 432
忘了有多久
忘了有多久 2020-12-06 03:52

I am just missing something.

Very simple or so I thought - using jquery - Based on the value selected in the Workers dropdown, I want to display on

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 04:24

    Using AJAX is a great way to do what you are asking.

    Please forgive me if you already know this but in jQuery/javascript, you:

    • grab the value of the first select box

    • use AJAX code to send that to a secondary PHP file, which uses the data it receives to write some HTML code based on what the user chose

    • the newly constructed HTML is ECHOed back to the ajax routine, where it is received inside a success function

    • Inside the success function, you can use jQuery to replace the contents of the second dropdown

    Here is a detailed example, with explanations

提交回复
热议问题