I am pasting pseudo code
***********************vfpage******************************
<apex:page standardController="Movie__c" extensions="Movietable" id="p">
<apex:form id="f">
<apex:pageBlock title="Movie Table" id="pageblock" >
<apex:commandButton action="{!save}" id="cb" value="Save" onclick="test();"/>
</apex:pageBlock>
<apex:pageBlock id="pb1">
<apex:pageBlockSection id="pbs" title="1st group" collapsible="false">
<apex:dataTable id="dt" value="{!mt}" var="mlist" cellpadding="5" cellspacing="0" width="100%">
<apex:column id="c">
<apex:facet name="header"><center>Select to ADD</center></apex:facet>
<apex:inputCheckbox value="{!mlist.select__c}" id="checkbox" > </apex:inputCheckbox>
</apex:column>
<apex:column >
<apex:facet name="header"><center>Material</center></apex:facet>
<apex:outputText value="{!mlist.name__c}" />
</apex:column>
</apex:dataTable>
</apex:pageBlockSection>
</apex:pageblock>
<script>
function test(){
addmat();
}
</script>
<apex:outputPanel id="newmaterial">
<script>
if('{!mtext}'=='25'){
alert(' plese select 26);
}
</script>
</apex:outputPanel>
<apex:actionFunction name="addmat" action="{!material}" id="newac" rerender="newmaterial"></apex:actionFunction>
</apex:form>
</apex:page>
**********************Apex class*******************
public class Movietable{
public List<Movie__c> mt{get;set;}
public List<Movie__c> mt1{get;set;}
public boolean m25{get;set;}
public String mtext{get;set;}
public Movietable(ApexPages.standardController stdController) {
mt=[select id, name__c,select__c,Cinemas__c from Movie__c];
}
public PageReference save() {
mt=[select id, name__c,select__c,Cinemas__c from Movie__c];
PageReference pr;
pr = new PageReference('/'+opp_id);
return null;
}
public PageReference material() {
Integer i=mt.size();
for(Integer j=0;j<i;j++){
if(mt[j].select__c==true && mt[j].name__c=='25'){
m25=true;
mtext='25';
}
}
return null;
}
}
I want on clicking save button after selecting material '25',alert should come saying please select 26 and it should stay on the same page until we select 26.once 26 is selected along with 25 the record should save and navigate to opportunity detail page.
As id's are dynamically generating in original code I couldn achieve it through javascript id's so please try to give me the solution using controller.
Many thanks in advance