$("document").ready(function() { var a = 3; $('#inp1').attr('oninput', '$(\'#inp2\').val(parseInt($(this).val()) + ( ',a,' * $(this).val())/100) '); }); 

a code that automatically transfers values ​​from one input to another, doing some math with values. manipulations. One value must be taken from the variable 'a', since I plan to change it when I press the buttons. The question is how to do this? as I indicated, it does not work, although it is written in all sources that this is done so. thank

  • Show your html - Daniel

1 answer 1

 $(document).ready(function() { var a = 3; $('#inp1')[0].oninput = function() { var value = +$(this).val(); $('#inp2').val(value + (a * value) / 100); }; });