I am trying to learn the magic of Javascript. What I am trying to do here is to add / remove text in div when checkbox is unchecked / checked.
This is me trying to do somekind of shopping cart:
function addCartItem(checkboxElement,cartElement,cartItemElement){
var s = "";
if(checkboxElement.checked == true){
s = document.getElementById(cartItemElement).innerHTML += checkboxValue;
updatePrice();
}
else{
s = document.getElementById(cartItemElement).innerHTML = checkboxValue;
s = s.replace(s,"");
updatePrice();
}
}
I cant get this to work, it wont remove the value from the unchecked checkbox.
UPDATE I have this checkbox calling function like this:
<input type="checkbox" onclick="addCartItem(this,'cartElement','cartItemElement');" value="StarBreeze: TWD Demo |1337">
Aucun commentaire:
Enregistrer un commentaire