I write a function to calcluate the price of some books (that are selected in a list) but It doesn't work correctly.
function priceCal(bookid,price){
if (document.getElementById(bookid).checked) {
document.getElementById('price').innerHTML=parseInt(document.getElementById("price").innerHTML)+price;
}
}
I call it for examle in one book like this:
<input
type="checkbox"
name="bookList"
value="book3"
id="bookList_3"
onChange="priceCal('bookList_3','50');"
>
But it doesn't do anything! What's wrong in sending arguments?! The price is a <p>
tag with 0 value (for default)