Selecting an option from one drop down populates other input fields

前端 未结 2 452
青春惊慌失措
青春惊慌失措 2021-01-24 08:12

I am trying to figure out how to populate other tags with a specific text after selecting from a drop down.

So if the drop down and another drop down below it the foll

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 08:19

    For predefined values like what you have, you can use the following jQuery/JavaScript code:

    $(function() {
        $('#dropDown1').change(function(){
           $('#dropDown2').val('You chose ' + this.value);
        });
    });
    

    JS Fiddle here: http://jsfiddle.net/vleong2332/82w7p0a6/

    Here is the example to change dropDown1 when dropDown2 changes. http://jsfiddle.net/vleong2332/82w7p0a6/1/

提交回复
热议问题