武力:<input name=i1 value=30 onpropertychange=check()>
<input value=+ type=button onclick="if(s.value>0&&i1.value<100)i1.value-=-1">
<input value=- type=button onclick="if(i1.value>30)i1.value-=1">
<br>
智力:<input name=i2 value=30 onpropertychange=check()>
<input value=+ type=button onclick="if(s.value>0&&i2.value<100)i2.value-=-1">
<input value=- type=button onclick="if(i2.value>30)i2.value-=1">
<br>
魅力:<input name=i3 value=30 onpropertychange=check()>
<input value=+ type=button onclick="if(s.value>0&&i3.value<100)i3.value-=-1">
<input value=- type=button onclick="if(i3.value>30)i3.value-=1">
<br>剩余:<input readOnly name=s value=100>
<script>
function check(){
s.value=100-(i1.value-i1.defaultValue)-(i2.value-i2.defaultValue)-(i3.value-i3.defaultValue)
}
</script>

解决方案 »

  1.   

    我是按回车键测试的,呵呵武力:<input name=i1 value=30 onpropertychange=check()>
    <input value=+ type=button onmousedown="timer=setInterval('if(s.value>0&&i1.value<100)i1.value-=-1',100)" onmouseout=clearInterval(timer) onmouseup=clearInterval(timer)>
    <input value=- type=button onmousedown="timer=setInterval('if(i1.value>30)i1.value-=1',100)"
    onmouseout=clearInterval(timer) onmouseup=clearInterval(timer)>
    <br>
    智力:<input name=i2 value=30 onpropertychange=check()>
    <input value=+ type=button onmousedown="timer=setInterval('if(s.value>0&&i2.value<100)i2.value-=-1',100)"
    onmouseout=clearInterval(timer) onmouseup=clearInterval(timer)>
    <input value=- type=button onmousedown="timer=setInterval('if(i2.value>30)i2.value-=1',100)"
    onmouseout=clearInterval(timer) onmouseup=clearInterval(timer)>
    <br>
    魅力:<input name=i3 value=30 onpropertychange=check()>
    <input value=+ type=button onmousedown="timer=setInterval('if(s.value>0&&i3.value<100)i3.value-=-1',100)"
    onmouseout=clearInterval(timer) onmouseup=clearInterval(timer)>
    <input value=- type=button onmousedown="timer=setInterval('if(i3.value>30)i3.value-=1',100)"
    onmouseout=clearInterval(timer) onmouseup=clearInterval(timer)>
    <br>剩余:<input readOnly name=s value=100>
    <script>
    var timer=null;
    function check(){
    s.value=100-(i1.value-i1.defaultValue)-(i2.value-i2.defaultValue)-(i3.value-i3.defaultValue)
    }
    </script>