Ibn Qudama, (may the mercy of Allah be upon him), said: "As soon as the ill person during prayer is able to do what he was not able to do when he commenced the prayer, whether it be standing, sitting, bowing, prostrating, or bowing, then he should move on and build on what has been already completed from his prayer. The same if he began the prayer completely capable of performing all actions, then suddenly became unable to perform certain actions. In this case he continues praying in the best shape he can and builds on what he previously had completed as though nothing has changed in his condition."1 The evidence is: hadith Umran Bin Hossayn, (may Allah be pleased with him), who said, "I had bawaseer (hemorrhoids) so I asked the Prophet (peace be upon him), about salaat, and he said: 'Pray standing up; if you cannot, then sitting down; if you can not, then on your side.' "2
From the book What Should You Do in the Following Situations... ?
1 Al-Mughni ma’a al-Sharh al-Kabeer 1/782, and likewise in Al-Majmooa lil-Nawawi 4/318.
2 Sunan Abu Dawood 922 and Sahih Sunan Abu Dawood 815