javascript - JS autofill incremented score, edit previous fill in -
OK I wrote JS that input is filled automatically with digits incremented when adding score . Works fine how do I get this fact that if someone goes back to edit the previous input, it first decreases the value and then increases the correct number and adds it to the score.
How do I check ... Is it any editing on the input or just an input?
is below:
var score = 0; Function Checkfield (Val, ECSR) {Score = + + + + + VAL; Document.getElementById ('incr' + inscr) .value = score; } You can add scores of each field to each change with JQuery (
Not tested)):
& lt; Input name = "ex1" class = "inputline1" /> & Lt; Input name = "ex2" class = "inputline1" /> & Lt; Input name = "ex3" class = "inputline1" /> & Lt; Input name = "result-1" id = "result-1" />
and in your JS:
$ (document) .ready (function () {$ (".inputline 1"). Changes (function ( Val ($ ("# result-1"). Val (0); $ ("inputline1") each (function () {$ ("# result-1"). Val ($ ("# result-1" ) .val () + $ (this) .val ());}}})
In this code: We will reset the result values for all fields of line 1 and the class Add value of each input with inputline1.
Have fun!
Comments
Post a Comment