PIbd-23_Nevaeva_K.A._IP/front/scripts.js

35 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2023-02-28 13:11:24 +04:00
function Okclick(clicked) {
2023-03-27 21:58:26 +04:00
var obj1 = document.getElementById("obj1Input").value
var obj2 = document.getElementById("obj2Input").value
var typeInp = document.getElementById("typeSelect").value
2023-02-28 13:11:24 +04:00
var id = clicked;
var argument = "";
2023-03-27 21:58:26 +04:00
console.log(typeInp);
if (document.getElementById("typeSelect").value == "arr"){
console.log("aaa");
obj1= encodeURIComponent(obj1);
obj2 = encodeURIComponent(obj2);
console.log(obj1);
console.log(obj2);
}
2023-02-28 13:11:24 +04:00
if(id == "1"){
2023-03-27 21:58:26 +04:00
argument = ("GetSum?obj1=" + obj1 +"&obj2=" + obj2 + "&typeInp=" + typeInp);
2023-02-28 13:11:24 +04:00
}
else if (id == "2"){
2023-03-27 21:58:26 +04:00
argument = ("GetMinus?obj1=" + obj1 + "&obj2=" + obj2 + "&typeInp=" + typeInp);
2023-02-28 13:11:24 +04:00
}
else if( id == "3"){
2023-03-27 21:58:26 +04:00
argument = ("GetMult?obj1=" + obj1 + "&obj2=" + obj2 + "&typeInp=" + typeInp);
2023-02-28 13:11:24 +04:00
}
else if (id == "4"){
2023-03-27 21:58:26 +04:00
argument = ("GetDiv?obj1=" + obj1 + "&obj2=" + obj2 + "&typeInp=" + typeInp);
2023-02-28 13:11:24 +04:00
}
fetch ("http://127.0.0.1:8080/" + argument)
.then(response => response.text())
.then((response) => {
console.log(response)
2023-03-27 21:58:26 +04:00
document.getElementById("res").innerHTML = "Результат = " + response
2023-02-28 13:11:24 +04:00
})
}