Firstly sorry for the length. The code uses a string key to find the relevant element on the dom, then the second switch uses the string key to query the db with certain filter and where clause (or not incase of a date filter). This is mind boggling, I probably should have created an individualRead more