I'm trying to implement a feature in a terms and conditions page where the Agree button will be disabled until the user scrolls over all the conditions till the end. So, I tried to follow an existing example (http://jsfiddle.net/dy8bqzkm/) and change what best fits into my scenario, but I keep facing issues and errors. Any idea on how to implement this feature correctly?
HTML code:
<div class="container w-container">
<div class="termsdiv">
<div class="policy-section" style="max-height: 250px; overflow-y: auto;"
id="PolicySection">
<!-- Policy conditions are listed here between list and paragraph tags-->
</div>
</div>
<div class="buttonblok">
<button type="submit" class="agree w-button" id="AgreeBtn" disabled>I Agree</button>
<button type="submit" class="cancel w-button" id="CancelBtn">Cancel</button>
</div>
</div>
JavaSript code:
<script>
document.getElementsById("PolicySection")[0].addEventListener("scroll", checkScrollHeight,
false);
function checkScrollHeight() {
var policyElement = document.getElementsById("PolicySection")[0]
if ((policyElement.scrollTop + policyElement.offsetHeight) >= policyElement.scrollHeight)
{
document.getElementsById("AgreeBtn")[0].disabled = false;
}
}
</script>
