I assume you’re asking about the US?
That order of who becomes the president in the event of the current president’s incapacity to fulfill the role is called the line of succession.
According to the Wikipedia article this is the order of based on current legislation:
1 Vice President and President of the Senate—Dick Cheney
2 Speaker of the House of Representatives—Nancy Pelosi
3 President pro tempore of the Senate—Robert Byrd
4 Secretary of State—Condoleezza Rice
5 Secretary of the Treasury—Henry Paulson
6 Secretary of Defense—Robert Gates
7 Attorney General—Michael Mukasey
8 Secretary of the Interior—Dirk Kempthorne
9 Secretary of Agriculture—Ed Schafer
— Secretary of Commerce—Carlos Gutierrez (non-natural)†
— Secretary of Labor—Elaine Chao (non-natural)†
10 Secretary of Health and Human Services—Mike Leavitt
11 Secretary of Housing and Urban Development—Steve Preston
12 Secretary of Transportation—Mary Peters
13 Secretary of Energy—Samuel Bodman
14 Secretary of Education—Margaret Spellings
15 Secretary of Veterans Affairs—James Peake
16 Secretary of Homeland Security—Michael Chertoff
† Non-natural born citizens (who are these indicated cabinet members) are ineligible to serve as the president.
If there’s any sort of calamity that has rendered the above members of government unable to serve as president I think it’s just presumed that there’s no point in naming additional staff as the current administration would likely be unable to function. Thus the whole law of succession wouldn’t be enforceable or valid.