I'm having some problems with some javascript / visualforce integration.
What i'd like to do is when the user clicks a button do some javscript error checking calling and if it fails, display a pop up and stay on the page without refreshing (i.e. i don't want to lose the client side stuff). I have the error checking working,and i prevent the page from submiting. i'm not sure if i did it right- i'm adding an action to the command button and adding an onSubmit method to the form.
If it passes- generate a string from that check method and pass it to the apex controller. I'm stuck on this too.
<apex:page extensions="customizationExtension" standardController="Customization__c" standardcontroller="Customization__c"><apex:messages />
<script>
function check(){
var flag = false;
var successCodes = "start";
// do a bunch of error checking.
if (flag=== true){
alert("Please make a selection for each field");
return false;
}
// <--------------------- Send the success Codes to controller??
return true;
};
</script>
<apex:form onsubmit="check()">
<apex:pageblock mode="maindetail" title="{!$ObjectType.Customization__c.label} Detail">
<apex:pageBlockButtons >
<apex:commandButton action="{!mySave}" value="Generate" onclick="return check();" />
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
Apex:
public pagereference mySave(){
system.debug(test);
PageReference p = new PageReference('/001');
return p;
}