How To Control Input Type Dropdown Select Options Menu With Jquery

前端 未结 1 818
隐瞒了意图╮
隐瞒了意图╮ 2021-01-26 16:24

I am creating a web site. In this web site , there is a form. I have added 3 dropdown menus in this form like below. Now I want to when someone selects the number 5 from Adults

1条回答
  •  一向
    一向 (楼主)
    2021-01-26 17:09

    Here is the solution as per your explanation:

    $('#children').change(function() {
        var children = $('#children').val();
        var infants = $('#infants').val();
        var adults = $('#adults').val();
        var total_pending;
       if((parseInt(adults) + parseInt(children)) < totalAdultChild){
         total_pending = totalAdultChild - (parseInt(adults) + parseInt(children));
         new_infants = parseInt(infants) + parseInt(total_pending);
         $('#infants').val(new_infants);
       }
     });
    });
    

    DEMO: https://codepen.io/creativedev/pen/aKaJxW

    0 讨论(0)
提交回复
热议问题