Try this:
var $inputs = $('.liste_couleur_qty li input');
$inputs.keyup(function() {
var result = 0;
$inputs.each(function(){
result += parseInt(this.value, 10);
});
$('#qtyvalue').html(result);
});
This would need to be in a document ready handler or in a script block after the elements in question (many people put their scripts at the end of the body).
In your code, input.onkeyup = ...
wouldn't work because there is no variable input
(it doesn't automatically pick up all input elements), and also using someElement.onkeyup =
only lets you attach a handler to one element at a time. Use jQuery to bind the keyup handler instead. Also, to use the total at the end just use result
, using result.value
wouldn't work.