Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can someone tell me why the code bellow never enter in the else cycle?

JavaScript
if ($("#chbShoutcastV2").is(':checked')) {

                                var v2 = document.getElementById('lblPrice').innerHTML;
                                var cena = "399";
                                var suma2 = Number(v2) + Number(cena);

                                document.getElementById("lblPrice").innerHTML = suma2;
                            }
                            else {
                                var v2 = document.getElementById('lblPrice').innerHTML;

                                var cena = "499";
                                var suma2 = number(v2) + Number(cena);

                                document.getElementById("lblPrice").innerHTML = suma;
                            }

thanks,
Posted
Updated 18-Dec-15 0:41am
v2
Comments
Andy Lanng 18-Dec-15 7:12am    
Well the syntax of the check is sound: https://jsfiddle.net/8wLvh0dd/

1 solution

Probably because it has syntax errors

JavaScript
if ($("#chbShoutcastV2").is(':checked')) {

    var v2 = document.getElementById('lblPrice').innerHTML;
    var cena = "399";
    var suma2 = Number(v2) + Number(cena);

    document.getElementById("lblPrice").innerHTML = suma2;
}
else {
    var v2 = document.getElementById('lblPrice').innerHTML;

    var cena = "499";
    var suma2 = Number(v2) + Number(cena); // "Number", not "number"

    document.getElementById("lblPrice").innerHTML = suma2; // suma2 not suma
}
 
Share this answer
 
Comments
thekoko89 18-Dec-15 7:02am    
its not that on the end of the code i try to print the state of the check box and when i check it says true but when i uncheck it stays true, does not goes to false
F-ES Sitecore 18-Dec-15 7:21am    
Well it works for me, so there might be an issue with the code you're not sharing. It could be you have multiple checkboxes with the same id, or some other issue.
thekoko89 18-Dec-15 8:29am    
the rest of the code is asp.net code this is the only javascript :/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900