The onchange function can run properly but I face some problem that the $.post function is not working
Here is html
<input type="checkbox" id="chk" value="3" onchange="checkradio(this.value)"/>
Here is javascript
var total=0;
function checkradio(serid) {
var num = 0;
$.post( "getserprice.php",{ serid: serid}, function( data ) {
alert(data);
num = data;
})
if (document.getElementById('chk').checked) {
total = total + num;
} else {
total = total - num;
}
}
Here is PHP
$price = 3;
echo $price;