35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
function Okclick(clicked) {
|
|
var obj1 = document.getElementById("obj1Input").value
|
|
var obj2 = document.getElementById("obj2Input").value
|
|
var typeInp = document.getElementById("typeSelect").value
|
|
var id = clicked;
|
|
var argument = "";
|
|
console.log(typeInp);
|
|
if (document.getElementById("typeSelect").value == "arr"){
|
|
console.log("aaa");
|
|
obj1= encodeURIComponent(obj1);
|
|
obj2 = encodeURIComponent(obj2);
|
|
console.log(obj1);
|
|
console.log(obj2);
|
|
}
|
|
if(id == "1"){
|
|
argument = ("GetSum?obj1=" + obj1 +"&obj2=" + obj2 + "&typeInp=" + typeInp);
|
|
}
|
|
else if (id == "2"){
|
|
argument = ("GetMinus?obj1=" + obj1 + "&obj2=" + obj2 + "&typeInp=" + typeInp);
|
|
}
|
|
else if( id == "3"){
|
|
argument = ("GetMult?obj1=" + obj1 + "&obj2=" + obj2 + "&typeInp=" + typeInp);
|
|
}
|
|
else if (id == "4"){
|
|
argument = ("GetDiv?obj1=" + obj1 + "&obj2=" + obj2 + "&typeInp=" + typeInp);
|
|
}
|
|
fetch ("http://127.0.0.1:8080/" + argument)
|
|
.then(response => response.text())
|
|
.then((response) => {
|
|
console.log(response)
|
|
document.getElementById("res").innerHTML = "Результат = " + response
|
|
})
|
|
|
|
}
|