I am currently working on a feature that will increment and store poll tallies in local storage if selected. While I have successfully implemented the poll count functionality, I am facing challenges when it comes to individually incrementing each of the three choices and saving them to local storage.
let pollCount = 0;
function getPollCount() {
return "Total Votes: " + pollCount;
}
function incrementPollCount() {
let nominee1 = document.getElementById("ges");
let nominee2 = document.getElementById("glp");
let nominee3 = document.getElementById("prs");
if (nominee1.checked) {
pollCount++;
} else if (nominee2.checked) {
pollCount++;
} else if (nominee3.checked) {
pollCount++;
}
}
<main>
<h2>Please Select Nominee!</h2>
<form name="nominee" onsubmit="voteSubmit()">
<label>
<input type="radio"
name="nominee" id="ges" value="Gibson ES-335">
</label> Gibson ES-335
<div id="orderTotal1">
<p id="p1"></p>
<script>document.write(getPollCount())</script>
</div>
<label>
<input type="radio"
name="nominee" id="glp" value="Gibson Les Paul">
</label>
Gibson Les Paul
<div id="orderTotal2">
<p id="p2"></p>
<script>document.write(getPollCount())</script>
</div>
<label>
<input type="radio"
name="nominee" id="prs" value="Paul Reed Smith">
</label>
Paul Reed Smith
<div id="orderTotal3">
<p id = "p3"></p>
<script>document.write(getPollCount())</script>
</div>
<input type="submit"
name="select" value="Select" onsubmit="incrementPollCount()">
</form>
</main>