There are 3 routes from St Pancras to Portsmouth :
tube (Northern) to Waterloo, then train
tube (Victoria) to Victoria, then train
train (Thameslink line) to East Croydon, then another train to Portsmouth.
You can certainly buy a ticket for all routes online.
However, if you want to buy a ticket at St Pancras, go and ask at the National Rail ticket counters in the non international route part of the station, not at the London Underground ticket counter.
© 1962-2020 The Bulletin