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
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