added click event to activate the navbar button save the index in var i