Donnerstag, 11. August 2016

HOW TO MAKE A CALCULATOR IN APEX

Calculator is very important in apex. It is possible to make it with Javascript and Jquerry.

With this Javascript Code ,we can make a sample Calculator:



Put this Code in Function and Global Variable Declaration:
function calcul(x,y){
 
    $("#Addition").click(function() {
document.getElementById("RESULT").value = add(x,y);
    });
                        $( "#Multiplication" ).click(function() {
    document.getElementById("RESULT").value = mult(x,y);
   });
 
                        $( "#Soustraction" ).click(function() {
    document.getElementById("RESULT").value = Sub(x,y);
   });
 
     $( "#Division" ).click(function() {
    document.getElementById("RESULT").value = Div(x,y);
   });
 
     $( "#Modulo" ).click(function() {
    document.getElementById("RESULT").value = Mod(x,y);
   });
}


function add(x, y) {
 
    return x + y;
}


function mult(x, y) {
 
    return x * y;
}

function Sub(x, y) {
 
    return x - y;
}


function Div(x, y) {
 
    return x / y;
}

function Mod(x, y) {
 
    return x % y;
}

Create 3 Items X,Y and Result like in a below Image. Make the Buttons too
In the Button set "action:redirect to URL et put this Code:
javascript:calcul(parseInt(document.getElementById('P1_X').value),parseInt(document.getElementById('P1_Y').value));

This show like the below image






Demo

Keine Kommentare:

Kommentar veröffentlichen