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

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

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -