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
Salesforce Learner 8Salesforce Learner 8 

I Have a JavaScriptfunction in my Visualforcepage and I want that to be executed depending on the if and else condition of the two or more fields .

Ashish GargAshish Garg
In javasciript, before method call, have a variable (boolean, which will decide if to execute the method) and get value from apex class getter method. The getter method will return TRUE / FALSE depending on the required field vaules.

JavaScript:
var ifToExecute = {!checkCondition};
if(ifToExecute) {
	callJsMethod();
}

Apex:
Public boolean getCheckCondition() {
	// ToDo: combine your fields condition here and accordingly send response
	return true;
}

Thanks,
Ashish Garg
Email: ashish6mains@gmail.com
Mob: +91-8952827377