How to get if else to work

I have this button. When i click. it will give me first popup or second popup.
How can i check whether is the first popup or the second popup?

Can i use if else method. or if there are other method to use.

Thanks in advance.