Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Created January 3, 2023 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfontjr/83210a57ccafed9f31bffc32aa1347e3 to your computer and use it in GitHub Desktop.
Save vfontjr/83210a57ccafed9f31bffc32aa1347e3 to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function($) {
"use strict";
$('#field_xxx').on('change', function() {
var total = 0;
if ( $(this).val().length > 0 ) {
const split_vals = $(this).val().split(", ");
var total = 0;
for (var i = 0; i < split_vals.length; i++) {
total += split_vals[i];
}
}
$(this).val(total);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment