jquery - Add Text box value on key press event and assign to second text box with sum -


i have 2 text boxes in form in first text box value changed randomly on every key press event.i want add values have changed , assign second text @ time of key press event.

like: first call: first text value:25 second text value:25 second call: first text box:45 second text value should be:25+45=70

here basic code you've described :

jsfiddle demo

html:

<body> <div id="box_1" class="box"></div><p></p> <div id="box_2" class="box"></div> </body> 

css

.box {   border:1px solid black;   width:100px;   height:50px;   display:inline-block; } 

javascript (jquery)

var val1 = 0; var val2 = 0;  $(document).ready(function() {     $(document).keypress(function(e)   {     val1 = math.floor(math.random() * 100) + 1;     val2 += val1;     $("#box_1").text(val1);     $("#box_2").text(val2);     }) }); 

i hope helps. :)

cheers, fjpackard.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -