Number 1 : Number 2 : Controller : public class Caluclator { Public Integer num1 {get;set;} Public Integer num2 {get;set;} Public String fun {get;set;} @RemoteAction public static Integer showText(Integer num1,Integer num2,String fun) { integer result=0; //return num1 + num2; if(fun == 'add') { result = num1 + num1; } else if(fun == 'sub') { result = num1 - num1; } else if(fun == 'mul') { result = num1 * num1; } else if(fun == 'div') { result = num1 / num1; } else if(fun == 'mod') { result = math.mod(Integer.valueOf(num1) , Integer.valueOf(num2)); } else if(fun == 'perc') { result = (num1/num2) * 100; } return result; } }",
"answerCount": 4,
"upvoteCount": 0,
"datePublished": "2021-03-01T08:58:58.000Z",
"author": {
"@type": "Person",
"name": "Rakesh Mallikarjun",
"url": "https://trailblazers.salesforce.com/profileView?u=0054S0000017P6TQAU",
"affiliation": {
"@type": "Organization",
"name": "Bit Order Technologies"
}
},
"suggestedAnswer": [
{
"@type": "Answer",
"text": "Wow, this looks fabulous! True, for me so far it looks very difficult, but I am learning. Together with our group, we are working on a project to build a similar calculator for solving geometry assignments. So I practice geometry a lot. By the way, this resource https://plainmath.net/secondary/geometry/high-school-geometry/congruence is the best thing that happened to me (I say it as a newbie student). I would also be grateful if you could recommend good resources for learning math!",
"upvoteCount": 0,
"url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T44muSAB",
"datePublished": "2021-09-30T13:26:08.000Z",
"author": {
"@type": "Person",
"name": "Developer Forums User (Inactive)",
"url": "https://trailblazers.salesforce.com/profileView?u=0054V00000H86IwQAJ",
"affiliation": {
"@type": "Organization",
"name": "Salesforce Developer Forums"
}
}
}
]
}
}
I am Trying to Perform Mathoperations in Calculator but its not working,can anyone help me to fix this issue.Here's My codeVF Page<apex:page controller="Caluclator"> <script type="text/javascript"> function textFunc() { var num1 = document.getElementById('n1').value; var num2 = document.getElementById('n2').value; String op; Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.Caluclator.showText}', num1,num2,op, function(result, event) { debugger; if(event.status) { // This is the way to get VF tag id to map result returned from call back function parameter result document.getElementById("{!$Component.pb.pbs.pbsi.numone}").innerHTML = result System.debug('Result--'+result); }{escape: true} }); } </script> Number 1 :<input id="n1" type="Number" /> Number 2 :<input id="n2" type="Number" /> <button type="button" onclick="textFunc('add')">Add</button> <button type="button" onclick="textFunc('sub')">Sub</button> <button type="button" onclick="textFunc('mul')">Mul</button> <button type="button" onclick="textFunc('div')">Div</button> <button type="button" onclick="textFunc('mod')">Mod</button> <button type="button" onclick="textFunc('perc')">Perc</button> <apex:pageBlock id="pb"> <apex:pageBlockSection id="pbs"> <apex:pageBlockSectionItem id="pbsi"> <apex:outputText id="numone"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock></apex:page>Controller :public class Caluclator { Public Integer num1 {get;set;} Public Integer num2 {get;set;} Public String fun {get;set;} @RemoteAction public static Integer showText(Integer num1,Integer num2,String fun) { integer result=0; //return num1 + num2; if(fun == 'add') { result = num1 + num1; } else if(fun == 'sub') { result = num1 - num1; } else if(fun == 'mul') { result = num1 * num1; } else if(fun == 'div') { result = num1 / num1; } else if(fun == 'mod') { result = math.mod(Integer.valueOf(num1) , Integer.valueOf(num2)); } else if(fun == 'perc') { result = (num1/num2) * 100; } return result; }}
Wow, this looks fabulous! True, for me so far it looks very difficult, but I am learning. Together with our group, we are working on a project to build a similar calculator for solving geometry assignments. So I practice geometry a lot. By the way, this resource https://plainmath.net/secondary/geometry/high-school-geometry/congruence is the best thing that happened to me (I say it as a newbie student). I would also be grateful if you could recommend good resources for learning math!