They use something called piddle packs.
For the ladies, you're right, they actually wear a kind of diapers
to let them pee. After doing it, they'll throw it away once they
land at their destination.
For the men, it takes abit of skill to unzip their suit all the way
down to where their penis is, so they can connect the hose....as
you know fighter jocks wear alot of layers of clothing (flightsuit,
g-suit, boxers/underwear, etc etc). Once they're done, they gotta
zip it back up all the way again. Remember they gotta do all this
while still flying their plane in the air, so its not only
difficult, its dangerous too. (Autopilot helps in this case, but
not much)
Rumour has it that a fighter pilot once accidentally ejected
himself out of his fighter while moving around the cockpit trying
to get his suit off to pee. Think he accidentally pulled the
ejection lever between the legs... Dont know what happened to the
guy tho...
Anyways, one of the fighter pilot's code and rule of thumb is this:
Always empty your bladder/bowels before EVERY mission. That way u
have a lesser risk of being forced to "do it" up there.