0

I am making an enrollment system in which users can select courses that they wish to take. It is a multi-page website where users first select a topic then they are directed to a new page where a list of courses associated with that topic is loaded from a MySQL database. When the user finds a course they want they click on a button and the course is added to a session variable with an AJAX call. I want to add an image or text that lets the user know that they added that course once they do. Currently there is no way the user can tell if they added the course or not. This of course is easily done when the user first adds the course. I can have a hidden image that is toggled on click. This however will be forgotten on page reload.

The question is, how can I flag the course(s) they added if they reload the page or leave that topic's page and later come back to it?

A possible solution that I came up with was to upon every page load to search the list of courses that are in the session variable for matches on that current page, then set the "Added" image to visible using jQuery. Is this a good solution? Is there a better one? I hope this is not too open-ended.

mattsburg
  • 13
  • 2
  • you are on the right track, use in_array to find out which courses the user has selected and add css them in your list – mdamia Aug 19 '15 at 18:51

1 Answers1

0
  1. yes you can do it as you described on your own (the jQuery way)
  2. maybe a:visited could do the job for you (i don't think so but you never know before trying)

regards :)

Axel
  • 3,331
  • 11
  • 35
  • 58
  • 1
    Thanks Axel! I had not thought of using :visited at all. I did some research into using this and came across this [post](http://stackoverflow.com/questions/1210871/use-jquery-to-select-visited-links). Check out Amens solution to storing and changing class based on visited urls. Its a little more than I am trying to get into based on time constraints but I found it interesting. I think I'll just do the jQuery way. – mattsburg Aug 19 '15 at 19:33