The reason you are getting the error is that you are trying to bind a JavaScript function to a WordPress PHP hook.
Bind your JavaScript handler to the form’s submit event:
$( "#your-form" ).submit(function( event ) {
//Select checkboxes by id
var $checkboxes = $('input[id=checkboxprice]');
//Set event
$checkboxes.on('change', function ()
{
var totalPrice = 0;
$checkboxes.each(function()
{
//Sum values of checkboxes
if(this.checked)
totalPrice = totalPrice + parseInt(this.value);
});
$("#price").val(totalPrice);
});
event.preventDefault();
});
Place the relevant code in a JavaScript file and enqueue it:
https://developer.wordpress.org/reference/functions/wp_enqueue_script/