I assume that you're looking at the following page:
If it is, the field type could be the same.
The page is just showing that it could be done with other field types too.
With that being said, you simply need to adjust the field code and the if/else statement part in the sample code.
I hope this helps.