Доброго времени суток еще раз. В общем, замучался с таким кодом, почему-то при обращении по селекторам цсс, упорно возвращает обьект вместо числа.
<script>
function ddd (){
var elements = document.querySelectorAll('#allparam>.param input:first-child ');
var rrr = 0
for (var i=0; i<elements.length; i++) {
parseInt(elements[i].value, 10)
alert(typeof(elements[i])+ typeof(rrr))
rrr += elements[i].value
}
alert(rrr)
}
function counter1(e, idd) {
var val= parseInt(document.getElementById(idd).value, 10);
var new_val= val + e;
if (new_val>=50) {
new_val=50
}
if (new_val <= -50){
new_val= -50
}
document.getElementById(idd).value= new_val
}
</script>
<div id="allparam">
<div class="param">
<input id="health" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'health')" /> <input type="button" value="-5" onclick="counter1(-5, 'health')" />
<label for="health">Здоровье</label>
</div>
<div class="param">
<input id="beauty" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'beauty')" /> <input type="button" value="-5" onclick="counter1(-5, 'beauty')" />
<label for="beauty">Красота</label>
</div>
<div class="param">
<input id="streng" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'streng')" /> <input type="button" value="-5" onclick="counter1(-5, 'streng')" />
<label for="streng">Сила</label>
</div>
<div class="param">
<input id="education" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'education')" /> <input type="button" value="-5" onclick="counter1(-5, 'education')" />
<label for="education">Образованность</label>
</div>
<div class="param">
<input id="smart" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'smart')" /> <input type="button" value="-5" onclick="counter1(-5, 'smart')" />
<label for="smart">Интеллект</label>
</div>
<div class="param">
<input id="social" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'social')" /> <input type="button" value="-5" onclick="counter1(-5, 'social')" />
<label for="social">Социализированность</label>
</div>
<div class="param">
<input id="many" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'many')" /> <input type="button" value="-5" onclick="counter1(-5, 'many')" />
<label for="many">Финансы</label>
</div>
<div class="param">
<input id="luck" size="2" maxlength="2" value="0" readonly></label> <input type="button" value="+5" onclick="counter1(5, 'luck')" /> <input type="button" value="-5" onclick="counter1(-5, 'luck')" />
<label for="luck">Удачливость</label>
</div>
</div>