JSFiddle - React, Tailwind, and code Playground

HTML

<form>
    <input type="checkbox" name="milk" id="checkbox" value="10.00"/>£10.00<br/>
    <input type="checkbox" name="eggs" id="checkbox2" value="20.00"/>£20.00<br/>
    <input type="checkbox" name="cheese" id="checkbox3" value="30.00"/>£30.00<br/>
    If you buy <span>name of items here</span>, it will cost you a total of £<span>price here</span>.
    <input type="submit"/>
</form>

JavaScript

$(':checkbox').change(function() {
    var sum = 0;
    var names = $('form :checked').map(function(){
        sum += (this.value - 0);
        return this.name;
    }).get().join(',');
    
    var spans = $('form span');
    spans[0].innerHTML = names;
    spans[1].innerHTML = sum;
});