For any Pokemon that faint, click that Pokemon's name to mark it as fainted.
If you won, click the refill button, otherwise use the reset button to start a new attempt.
The refill button will automatically roll as many Pokemon as you marked as fainted, and fill in the missing spots on the team. No care is taken to team synergy at this stage, however.
When closing the page, it will automatically save your current progress and fill it in the next time you reload the page.