Sunday 15 April 2012

jquery - Divide percentage amongst text inputs -


How do these people go,

What do you say is that dividing one percent apart What is the best way to use input using Jquery? To wit. & lt; Input type = "text" value = "" name = "inputon" /> & lt; Input type = "text" value = "" name = "input two" /> & Lt; Input type = "text" value = "" name = "inputThree" /> & Lt; Input type = "text" value = "" name = "inputfire" />

This idea is assumed to be on the key of each of these inputs - is reduced by 100% and then divided and set as the value of the other fields goes.

In the end, if input 25 should be shown in the remaining field as the input value:

   & Lt; Input type = "text" value = "25" name = "inputtree" /> & lt; Input type = "text" value = "25" name = "inputfire" />   

As always, any help is appreciated

< P> You can try this approach ..
  $ ('input'). ('Keyup', function () {var val = this.value, $ allInputs = $ ('Input'); if (Val> 100) {$ allInputs.val (100 / $ allInputs.length);} And {var length $ ('Input'). No (this) .val ((100-val) / ($ allInputs.length- 1));}});   

However, the need to add some error checks

No comments:

Post a Comment