How do I enable a DIV to be removed on click?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do I enable a DIV to be removed on click?

Post by simonmlewis »

I want to give users "updates", via a DIV at the top of the screen. But for them to be able to click an 'X' to close it permanently.

It's kinda like sites do it for "this site uses cookies".

How does it work??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I enable a DIV to be removed on click?

Post by Celauran »

You mean like this? http://jsfiddle.net/NzfSJ/
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enable a DIV to be removed on click?

Post by simonmlewis »

I do - but does that make it disappear for the whole time you are on the site?
I'm using one *.inc file for tickets. and need to let Support know of developments. but once they know, via that DIV, I want them to be able to click the X, and it's gone permanently. Until I update it again. Or perhaps until they login and create a new session.

Otherwise, if the page was reloaded, would that not reappear?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I enable a DIV to be removed on click?

Post by Celauran »

Yes, this would reappear on page load. Sounds like what you need is more complex than simply hiding a div, though. You'll need to track what each user has seen. Cookies can handle that temporarily, but you may even want to persist that data so they aren't seeing a bunch of old notices again after having cleared their cache.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I enable a DIV to be removed on click?

Post by simonmlewis »

Or just abandon telling them. lol.
Thanks.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply