Your code needs to be inside of the register_click() function in order for your code to be able to access the page elements.