javascript - How to decrease number [value] before post? -


i not sure possible if user type numbers in input, want decrease number in hidden before post? example if type 1 output 0 or if type 2 output 1

<input class="decrease" type="text" name="number" value="" /> <input class="output" type="hidden" name="number" value="//decrease number//" /> 

hope 1 helps.

$(document).ready(function(){     $('.decrease').keyup(function(){         if($('.decrease').val()!="")         {             $('.output').val($('.decrease').val()-1);         }         else         {             $('.output').val("");         }      }); }); 

you have make sure user types in numbers. if user types in character, value of hidden input nan.

see documentation more examples , information.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -