I have a form with three items with checkboxes and prices. In a paragraph underneath I have an area for the total price, and an area for the items selected. How can I update these two areas when each checkbox is checked?
<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>
How can I achieve this with jQuery or JavaScript? I don’t really want to use a textbox for putting the values in, I’d rather they were in-line text. So I want the object names in the first bit, and the total price in the second.
jQuery
html
demo
simple demo