div hover effect

movieprodw used Ask the Experts™

I have a div and it has a form in it, it is on the home page so I want it to show but if they are not logged in then I want to have it so that when they hover over the div it is grayed out and says [!] Please log in or create an account.

Any ideas of how to do that? I know to make it check to see if they are logged in but how do you make a div have an affect on hover like that.

Logged in
<div id="contentForm"><form>...</form></div>

NOT logged in
<div id="contentForm" class="login"><form>...</form></div>
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hello Leakim,

I am not looking for a greybox but I simply want the div holding the form to be grey with some words on it saying that they have to log in.

Carlos LlanosIT Manager
I would add JavaScript zone as this will probably require some to accomplish this.
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

If it is just html, then you need to use javascript to achieve that.

You can change the classname of div in javascript, after loading the page. For this you should have some variable to figure out, if logged in or not.

If you are using any server side programming like ASP/JSP, you should be able to generate the div with out without class at serverside itself..
nishant joshiTechnology Development Consultant
make a field like

<input type="hidden" id="login">true</input>

in your script you have to check

Sandeep KothariProject Lead
below is a sample code... might help ..
<div id='main' onmouseover="showAlert()" onmouseout="hideAlert()" style="height:400px;width:500px";>
<div id='login' class="frm">
<div id='alertid' class='loggedin'>Please Login to create an account!</div>

function showAlert(){

function hideAlert(){

Open in new window


Thanks for the help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial