Hi,
I have javascript which counts seperately every time 2 seperate buttons are clicked, this then outputs the amount on the same page. This works, however I am now trying to add a third value to output on the page which is the total of the clicks which i would calculate by adding the 2 attributes together. This just doesn't seem to be working though.
java
<script type="text/javascript">
var NextClick = 0;
var PrevClick = 0;
var TotalClicks = 0;
function getValueNext()
{
var y=document.getElementById("NextClick").value = ++NextClick
$('.NextClick').val(y);
}
function getValuePrev()
{
var x=document.getElementById("PrevClick").value = ++PrevClick
$('.PrevClick').val(x);
}
function getSumClicks()
{
var z= x + y
$('.TotalClicks').val(z);
}
</script>
Html
Clicked next <input class="NextClick" size="3" onfocus="this.blur();" value="0"> times.
Clicked prev <input class="PrevClick" size="3" onfocus="this.blur();" value="0"> times.
Clicked total <input class="TotalClicks" size="3" onfocus="this.blur();" value="0"> times.