3
I’m wondering how do I add two values that are set when I mark the checkbox.
i made this code,It doesn’t work as I expected,I wanted it to take the number that is already in the input and add another value when checking the checkbox,and remove the same amount that was added when unchecking.
$('#booster15p').change(function(){
if($(this).attr('checked')){
$('#tdmxp').val(10+1.5);
}else{
$('#tdmxp').val(11.5-1.5);
}
});
$('#booster50p').change(function(){
if($(this).attr('checked')){
$('#tdmxp').val(10+5);
}else{
$('#tdmxp').val(15-5);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<input type="checkbox" name="1.5" id="booster15p"/>Aumenta em 1.5
<input type="checkbox" name="5" id="booster50p"/>Aumenta em 5
<input class="tdmxp" id="tdmxp" value="10" >
Thanks, it worked great.I used method 1 q is much easier to understand kkk thank you very much
– War Night