Reputation: 13
I have a html file that has two buttons, approve and reject. I want that if someone clicks on the approve button, I want the box to disappear and display a message PERMANENTLY.
By permanently I mean that it should not return the box when I refresh the page.
Is it possible with JS or PHP or anything else?
Thanks.
Upvotes: 1
Views: 153
Reputation: 181
I expect you'll need to set a cookie when you put up the message. That's only permanent as long as they keep the cookie, though. For real permanence you'll need to associate the message state with their login/customer info and retrieve that every time they come back to the site. Which means you'll have to force a login before they get to the form.
The problem with trying to do something dynamic, then make it permanent, but only for that user, is that you have to get over the statelessness of the web. You have no idea who you're dealing with from one visit to the next. To get over that, you either need to tag them (by setting a cookie) so you'll recognize them on their next visit, or you need to make them identify themselves (by forcing a login).
Upvotes: 0
Reputation: 7712
js will not be able to do something like this by itself. you need some sort of back end server processing or a cookie that will detect the user when they go to the page and then save their button click in a server side db or client side cookie... then when the user comes back it checks the back end data source or the client side cookie and makes the changes either client side with js or server side with php
Upvotes: 0
Reputation: 23316
Is it possible with JS or PHP or anything else?
Yes.
For a more detailed answer supply a more detailed question.
Upvotes: 3
Reputation: 9491
You either need to store a cookie that you can check if they clicked or you need to store a list of IP's and what they clicked. That's the hard part
Hiding and displaying the box is as easy as using jquery and the onclick element in html.
Edit:
I agree with the above answer without more details it is hard to provide a working solution.
Upvotes: 0
Reputation: 168988
Uhm, presumably when someone clicks one of those buttons, you store a value somewhere indicating their action. You would normally check if the user has previously performed this action (or if it otherwise makes sense to display the buttons) and just not output them from your PHP script in that case.
Without more details about your code it'll be impossible to provide any more help than this.
Upvotes: 1