Rulings on changing the intention of a prayer after starting it
Question

Is it alright to change the intention of a prayer after beginning it?.
Praise be to Allah.Shaykh Ibn ‘Uthaymeen was asked about changing the intention in prayer. 
He replied: 
Changing the intention means either changing it from one specific thing to another, or from something general to something specific. This is not correct, but if it is changing it from something specific to something general, then there is nothing wrong with that. 
For example: 
Changing from one specific thing to another: A person wanted to change the Sunnah prayer of Duha to the regular prayer of Fajr which he had missed and wanted to make up. He said takbeer with the intention of offering two rak’ahs of Duha, then he remembered that he had not offered the regular prayer of Fajr, so he changed it to the regular prayer of Fajr. This is not valid, because the regular prayer of Fajr is two rak'ahs for which he should have had the intention from the beginning of the prayer. 
Another example is a man who started to pray ‘Asr, but whilst praying he remembered that he had not prayed Zuhr, so he intended this prayer to be Zuhr. This is also not valid, because the intention for a specific prayer must be there from the outset. 
With regard to changing from something general to something specific, such as if a person started to offer a general (i.e., naafil) prayer, then he remembered that he had not prayed Fajr or the Sunnah of Fajr, so he changed his intention to Fajr prayer or the Sunnah of Fajr – this is also not valid. 
But if he changes from something specific to something general, such as if he starts praying with the intention that it is the regular prayer of Fajr, then whilst he is praying he remembers that he has already offered this prayer, in that case he may change his original intention to the intention to simply offer a prayer. 
Another example is that of a man who starts to offer an obligatory prayer on his own, then a group (jamaa’ah) comes along, and he wants to change his obligatory prayer to a naafil prayer so that he may cut it short and offer two rak'ahs only, then offer the obligatory prayer with the group. This is permissible, because he is changing from something specific to something general. 
So the principle is: 
Changing from one specific thing to another is not valid; changing from something general to something specific is not valid; changing from something specific to something general is valid. 
End quote from Majmoo’ Fataawa al-Shaykh Ibn ‘Uthaymeen, 12/ Question no. 347. 
The Shaykh was also asked: 
Is it permissible to change one’s intention from one specific thing to another? 
He replied: It is not permissible to change one’s intention from one specific thing to another, or from something general to something specific. Rather it is only permissible to change one's intention from something specific to something general. 
An example of the first, changing one's intention from one specific thing to another, is changing the intention from praying Zuhr to praying ‘Asr. In this case the Zuhr prayer is invalidated, because one has turned away from it, and ha has not started ‘Asr prayer because that was not the intention from the outset. In that case both prayers must be made up. 
An example of the second, changing from something general to something specific, is when a person starts to pray a general naafil prayer, then turns the intention to a specific naafil prayer, then he changes it into regular Sunnah prayer, i.e., a man starts to pray with a general intention, then he wants to make it the regular Sunnah prayer of Zuhr – for example. But this does not count as the regular Sunnah prayer, because he did not have that intention from the outset. 
An example of the third, changing from something specific to something general, is when a person intends to offer the regular Sunnah prayer of Maghrib, then he decides to make it a general Sunnah prayer. This is valid and does not invalidate the prayer, because the intention to perform a specific prayer includes the intention to offer prayer in general, so if the specific intention is cancelled out, the general intention still remains, but if he does that, then his regular Sunnah prayer does not count because he has turned away from it. 
End quote from Majmoo’ Fataawa al-Shaykh Ibn ‘Uthaymeen, 12/ question no. 348. 
And Allaah knows best.