const data = { 0: [ "18000", "18500", "19100", "19700", "20300", "20900", "21500", "22100", "22800", "23500", "24200", "24900", "25600", "26400", "27200", "28000", "28800", "29700", "30600", "31500", "32400", "33400", "34400", "35400", "36500", "37600", "38700", "39900", "41100", "42300", "43600", "44900", "46200", "47600", "49000", "50500", "52000", "53600", "55200", "56900", ], 1: [ "19900", "20500", "21100", "21700", "22400", "23100", "23800", "24500", "25200", "26000", "26800", "27600", "28400", "29300", "30200", "31100", "32000", "33000", "34000", "35000", "36100", "37200", "38300", "39400", "40600", "41800", "43100", "44400", "45700", "47100", "48500", "50000", "51500", "53000", "54600", "56200", "57900", "59600", "61400", "63200", ], 2: [ "21700", "22400", "23100", "23800", "24500", "25200", "26000", "26800", "27600", "28400", "29300", "30200", "31100", "32000", "33000", "34000", "35000", "36100", "37200", "38300", "39400", "40600", "41800", "43100", "44400", "45700", "47100", "48500", "50000", "51500", "53000", "54600", "56200", "57900", "59600", "61400", "63200", "65100", "67100", "69100", ], 3: [ "25500", "26300", "27100", "27900", "28700", "29600", "30500", "31400", "32300", "33300", "34300", "35300", "36400", "37500", "38600", "39800", "41000", "42200", "43500", "44800", "46100", "47500", "48900", "50400", "51900", "53500", "55100", "56800", "58500", "60300", "62100", "64000", "65900", "67900", "69900", "72000", "74200", "76400", "78700", "81100", ], 4: [ "29200", "30100", "31000", "31900", "32900", "33900", "34900", "35900", "37000", "38100", "39200", "40400", "41600", "42800", "44100", "45400", "46800", "48200", "49600", "51100", "52600", "54200", "55800", "57500", "59200", "61000", "62800", "64700", "66600", "68600", "70700", "72800", "75000", "77300", "79600", "82000", "84500", "87000", "89600", "92300", ], 5: [ "35400", "36500", "37600", "38700", "39900", "41100", "42300", "43600", "44900", "46200", "47600", "49000", "50500", "52000", "53600", "55200", "56900", "58600", "60400", "62200", "64100", "66000", "68000", "70000", "72100", "74300", "76500", "78800", "81200", "83600", "86100", "88700", "91400", "94100", "96900", "99800", "102800", "105900", "109100", "112400", ], 6: [ "44900", "46200", "47600", "49000", "50500", "52000", "53600", "55200", "56900", "58600", "60400", "62200", "64100", "66000", "68000", "70000", "72100", "74300", "76500", "78800", "81200", "83600", "86100", "88700", "91400", "94100", "96900", "99800", "102800", "105900", "109100", "112400", "115800", "119300", "122900", "126600", "130400", "134300", "138300", "142400", ], 7: [ "47600", "49000", "50500", "52000", "53600", "55200", "56900", "58600", "60400", "62200", "64100", "66000", "68000", "70000", "72100", "74300", "76500", "78800", "81200", "83600", "86100", "88700", "91400", "94100", "96900", "99800", "102800", "105900", "109100", "112400", "115800", "119300", "122900", "126600", "130400", "134300", "138300", "142400", "146700", "151100", ], 8: [ "53100", "54700", "56300", "58000", "59700", "61500", "63300", "65200", "67200", "69200", "71300", "73400", "75600", "77900", "80200", "82600", "85100", "87700", "90300", "93003", "95800", "98700", "101700", "104800", "107900", "111100", "114400", "117800", "121300", "124900", "128600", "132500", "136500", "140600", "144800", "149100", "153600", "158200", "162900", "167800", ], 9: [ "56100", "57800", "59500", "61300", "63100", "65000", "67000", "69000", "71100", "73200", "75400", "77700", "80000", "82400", "84900", "87400", "90000", "92700", "95500", "98400", "101400", "104400", "107500", "110700", "114000", "117400", "120900", "124500", "128200", "132000", "136000", "140100", "144300", "148600", "153100", "157700", "162100", "167300", "172300", "177500", ], 10: [ "67700", "69700", "71800", "74000", "76200", "78500", "80900", "83300", "85800", "88400", "91100", "93800", "96600", "99500", "102500", "105600", "108800", "112100", "115500", "119030", "122600", "126300", "130100", "134000", "138000", "142100", "146400", "150800", "155300", "160000", "164800", "169700", "174800", "180000", "185400", "191000", "196700", "202600", "208700", ], 11: [ "78800", "81200", "83600", "86100", "88700", "91400", "94100", "96900", "99800", "102800", "105900", "109100", "112400", "115800", "119300", "122900", "126600", "130400", "134300", "138300", "142400", "146700", "151100", "155600", "160300", "165100", "170100", "175200", "180500", "185900", "191500", "197200", "203100", "209200", ], 12: [ "123100", "126800", "130600", "134500", "138500", "142700", "147000", "151400", "155900", "160600", "165400", "170400", "175500", "180800", "186200", "191800", "197600", "203500", "209600", "215900", ], 13: [ "131100", "135000", "139100", "143300", "147600", "152000", "156600", "161300", "166100", "171100", "176200", "181500", "186900", "192500", "198300", "204200", "210300", "216600", ], 14: [ "144200", "148500", "153000", "157600", "162300", "167200", "172200", "177400", "182700", "188200", "193800", "199600", "205600", "211800", "218200", ], 15: [ "182200", "187700", "193300", "199100", "205100", "211300", "217600", "224100", ], 16: ["205400", "211600", "217900", "224400"], 17: ["225000"], 18: ["250000"], }; const basiclevelJune = document.getElementById("basiclevelJune"); const basicpayJune = document.getElementById("basicpayJune"); const basiclevelJuly = document.getElementById("basiclevelJuly"); const basicpayJuly = document.getElementById("basicpayJuly"); const hracity = document.getElementById("hracity"); const highertpta = document.getElementById("highertpta"); const calculate = document.getElementById("calculate"); const resulttable = document.getElementById("result"); basiclevelJune.onchange = function () { let markup = ''; if (basiclevelJune.value != -1) { data[`${basiclevelJune.value}`].forEach((ele) => { markup += ``; }); basicpayJune.innerHTML = markup; } else { basicpayJune.innerHTML = markup; } }; basiclevelJuly.onchange = function () { let markup = ''; if (basiclevelJuly.value != -1) { data[`${basiclevelJuly.value}`].forEach((ele) => { markup += ``; }); basicpayJuly.innerHTML = markup; } else { basicpayJuly.innerHTML = markup; } }; calculate.onclick = function (e) { e.preventDefault(); if ( basiclevelJune.value != -1 && basiclevelJuly.value != -1 && basicpayJune.value != -1 && basicpayJuly.value != -1 && hracity.value != 0 && highertpta.value != 0 ) { $.ajax({ type: "POST", url: "actions.php?action=calculation", data: "basiclevelJune=" + $("#basiclevelJune").val() + "&basicpayJune=" + $("#basicpayJune").val() + "&basiclevelJuly=" + $("#basiclevelJuly").val() + "&basicpayJuly=" + $("#basicpayJuly").val() + "&hracity=" + $("#hracity").val() + "&highertpta=" + $("#highertpta").val(), success: function (result) { // $("#calculator")[0].reset(); if (result == "1") { alert("Please Try Again"); } else { const { julyall, juneall } = JSON.parse(result); setMarkup(juneall, julyall); $("#result").show("slow"); } }, }); } else { alert("Please Select the values"); } }; $("#resetval").click(formReset); function setMarkup(juneall, julyall) { basicpayJune.innerHTML = ``; $("#basicpayresult").html(`BASIC PAY ${juneall.basicpayJune} ${julyall.basicpayJuly}`); $("#hra").html(`HRA ${juneall.hra} ${julyall.hra}`); $("#ta").html(`TA ${juneall.ta} ${julyall.ta}`); $("#da").html(`DA ${juneall.da} ${julyall.da}`); $("#total").html(`TOTAL ${juneall.total} ${julyall.total}`); $("#salarydiff").html(`SALARY DIFFERENCE ${Math.abs( juneall.total - julyall.total )}`); } function formReset() { $("#calculator")[0].reset(); $("#result").hide("slow"); }