Skip to content

Instantly share code, notes, and snippets.

@JacksonGariety
Created January 11, 2014 19:07
Show Gist options
  • Save JacksonGariety/8375315 to your computer and use it in GitHub Desktop.
Save JacksonGariety/8375315 to your computer and use it in GitHub Desktop.
var fields = [document.querySelector('#field-1-id'), document.querySelector('#field-2-id')]
fields.forEach(function (field) {
field.addEventListener('keydown', function (event) {
var total = 0
fields.forEach(function (field) {
total += field.value
})
document.querySelector('#calculated-field-id').value = total
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment