Something along these lines? ...

$(document).ready(function() {
  var maxPt = 20
    , curPt = 0
    , trgts = $('input')
    ;
  trgts.attr({readonly:'readonly'}).val(0).each(function(i){
      var me = this, x = i, pv = trgts[i-1], nx = trgts[i+1];
      $(this).nextAll('.add:first').bind('click', function(){
          var u = pv ? (1*pv.value) : 0, v = (1*me.value);
          if(curPt < maxPt && (!x || (x && u > v))){
            me.value = v+1;
            ++curPt;
          }
        }).end()
        .nextAll('.sub:first').bind('click', function(){
            var u = nx ? (1*nx.value) : 0, v = (1*me.value);
            if(curPt > 0 && v > 0 && v > u){
              me.value = v-1;
              --curPt;
            }
          })
    });
});
</script>

<div>
  <input type='text' value='0' name='inp_A' size='2' />
  <span class='add'>+</span>&nbsp;/&nbsp;<span class='sub'>-</span>
</div>
<div>
  <input type='text' value='0' name='inp_B' size='2' />
  <span class='add'>+</span>&nbsp;/&nbsp;<span class='sub'>-</span>
</div>
<div>
  <input type='text' value='0' name='inp_C' size='2' />
  <span class='add'>+</span>&nbsp;/&nbsp;<span class='sub'>-</span>
</div>


On May 10, 7:56 pm, Chris Hall <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I'm looking for a very odd control, but I'm betting something like
> this exists.
>
> The control is a simple + and - (or even < and >) that will increment
> or decrement a field, but my catch is allowing the increment is
> conditional.
>
> For example, you have field A, field B, and field C and you have 20
> points to add to these fields.  You can only have as many points in
> field B as you do in field A, and likewise, you can only have as many
> points in field C as in field B.
> So your first selection must be 1 point in field A.  Then you can
> either put your next point also in field A or in field B.
>
> Does a form control even remotely like this exist?
>
> Many thanks for all the help!

Reply via email to