I am trying to make a chart that changes size relative to the amount of a variable. This variable will increase and decrease according to which checkbox the user ticks. The graphs display fine as I have already set the height in CSS to see how they look, though when I click the button "#submit" nothing occurs. Could someone point out the issue in my code?
Code:
//Vote count variables
var ag = 2;
var nag = 0;
//Make only one checkbox tickable.
$('input[type="checkbox"]').on('change', function() {
$('input[type="checkbox"]').not(this).prop('checked', false);
});
//Function to refresh the charts with new vote amounts.
function refreshChart() {
$(".for").css({
'height': ag * 60 + 'px;'
});
$(".for not").css({
'height': nag * 60 + 'px;'
});
}
//Refresh the charts for user on submit click.
$('#submit').click(function() {
if ($('#c1').prop('checked') == true) {
ag += 1;
}
if ($('#c2').prop('checked') == true) {
nag += 1;
}
refreshChart();
});
.results {
color: #111;
display: show;
align-items: center;
}
.for {
display: block;
margin: 0 auto;
background-color: #27AE5F;
width: 20px;
height: 100px;
padding: 20px;
text-align: center;
font-size: 11px;
color: #fff;
}
.not {
background-color: #c0392b;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="checkcont">
<div class="styleC">
<input id="c1" type="checkbox">
<label for="c1"> </label>
</div>
<p> I agree that the restrictions placed on imported cars should be removed or limited. </p> <br>
<div class="styleC">
<input id="c2" type="checkbox">
<label for="c2"> </label>
</div>
<p> I believe the current restrictions and regulations should not be altered. </p>
</div>
</div>
<div class="results">
<h2> The Current Standings of Opinions Submitted </h2>
<div class="for">
<p class="resultsNo yes"> 2 </p>
</div>
<div class="for not">
<p class="resultsNo no"> 0 </p>
</div>
</div>
<a id="submit"> Submit </a>
</div>
</div>
.for notin your selector in jquery. do you mean.for.not?