Removed the JS. Now it is fully PHP and works properly.