views:

312

answers:

6

I have no idea how to do this and I need assistance please. I am using asp.net and I have a div with overflow:auto set. The div shows terms and agreements. I also have a asp.net checkbox control with visible set to "false". What I want is a way to make checkbox visible = "true" only after the user scrolls all the way to the bottom. I was trying to add a javascript function called when onmouseup was triggered but I don't think this code is working and I have no idea as to how to make the checkbox control visible = "true" from the javascript code.

function checkScrollPosition(elem) {
    if(elem.scrollHeight<(elem.scrollTop+elem.offsetHeight)) {
    document.getElementById("CheckBox1").style.visibility = "visible";
    }
A: 

Undoubtedly you are trying to make sure someone has read a EULA or some sort of agreement.

The only way to do this semi-effectively is with client-side JavaScripting and you need to raise an event on the scroll. I would suggest creating a control that LOOKS LIKE your div with overflow set with your own scroll control on the left that LOOKS LIKE the browser scroll.

This way you can raise a scroll event on a mouse action that looks at the current height property or something that determines the user's location on the target DIV.

Ian Patrick Hughes
A: 

Why not just put the checkbox at the bottom of the div? They would have to scroll to get there anyway...

Chris Lively
I am doing that for now but it's not what is wanted. I need to figure out how to do this.
jumbojs
A: 

For my own part, this is quite possibly one of the most annoying designs in existence. Scrolling the EULA is not the same as reading it - if you want to really be sure they read it, you'll have to quiz them on the content. One question on the content of each paragraph should do it, with four multiple-choice answers for each... :-)

They're either going to read the EULA, or not. Making them scroll is not going to change that.

ScottSEA
Once again, it's not opinions I am looking for, it's an answer to my question. If somebody wants this, this is the way we do it. If you don't know how to answer the question please refrain.
jumbojs
+1  A: 

Your answer really doesn't lie in ASP.NET, but more on the Javascript side of things. Take a look at the jQuery framework, I would not be surprised at all if something like this is built-in or if someone has a plug-in that will do it. But ASP.NET is more about server-side processing than it is about client-side processing, and what you want is completely client-side.

Not saying that it couldn't be done in .NET, I'm sure it could, but it would be (IMO) more effort than it is worth when it's much easier to handle it in Javascript.

Sorry I don't have more detailed info for you, but dig around with jQuery, you'll likely find something you can either use or tweak to get exactly what you want.

EDIT: There's some jQuery code about halfway down this page that might have something you can use.

James McConnell
A: 

I believe you want to check if (div.clientHeight+div.scrollTop==div.scrollHeight).

Frank Schwieterman