IMHO sarebbe meglio utilizzare javascript lato client piuttosto che PHP.