function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vamsi krishna 106vamsi krishna 106 

VF page is not redirect when confirm is true?

Hi Guys,
controller

public class newpage{
public pagereference page2()
{
//here i need to redirect code...
}

}
<apex:page controller="newpage">
<script>
function conrimnew(e)
{
var con=confirm("Are u Sure>");
if(con){
return true;
else{
return false;
}
}
}
</script>
<apex:form>
<apex:inputfield value="{!some1}"/>
<apex:inputfield value="{!some2}"/>
<apex:commandbutton action="{!page2}" onclick="return conrimnew(event)" value="confirm"/>
</apex:form>
</apex:page>

but here when i click on that command button..it open the confirm box.for first time if u click on ok then it redirect to the URL.but 
when i click on CANCEL..after that when i click on the button ..then i open the confirm box...but now if i click on OK..
then it is not redirect to the page...please..
help me guys..

thanks in advance..

Thanks Vamsikrishna
pconpcon
Because you are using onclick it will not call the action correctly.  What you will want to do is to use the apex:actionFunction tag [1]

[1] http://salesforce.stackexchange.com/questions/19004/visualforce-onclick-doesnt-execute-action-or-rerender