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

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -