Added js function to change the state