I have this code that selects all the text fields with “record_” in them.
$('input[name^="record_"]').map(function() { total += $(this).val() * 1; });
But the fields with the name “record_1, record_2 and record_3” need to be * 8 not * 1.
How can i filter the search so that it only finds records that have numbers after 3?
I tried an IF function but the way ive done the above code means that “record_15” will be * 8 and not * 1 as it should be .
I know this should be simple but i cant get my head around it.
This works:
DEMO: http://jsfiddle.net/WKb7n/1/
It also avoids creating unnecessary variables or lookups inside the loop, which should make it more efficient.