-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator1.html
executable file
·56 lines (41 loc) · 1.47 KB
/
calculator1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html>
<head>
<!-- Name- Payel Bandyopadhyay, Student Number - 014174692 -->
<script type="text/javascript" >
function ajaxFunction()
{
var arg1 = document.getElementById("nm1").value;
var arg2 = document.getElementById("nm2").value;
var op = document.getElementById("opt1").value;
var xmlhttp= new XMLHttpRequest();
xmlhttp.open("GET","calc.php?arg1="+arg1+"&arg2="+arg2+"&op="+op,true);
xmlhttp.send();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState===4 && xmlhttp.status===200)
{
var newDiv = document.createElement("div");
newDiv.innerHTML = xmlhttp.responseText;
var nextElement = document.getElementById("nm1");
parentnode = nextElement.parentNode;
parentnode.insertBefore(newDiv, nextElement);
}
}
}
</script>
</head>
<body>
<form id = "frm1">
<input id = "nm1" type="text" name="arg1">
<select id = "opt1" name="op">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input id = "nm2" type="text" name="arg2">
<input id ="toto" type="button" value="Submit" onclick="ajaxFunction();"/>
<div id="divTest"> </div>
</form>
</body>
</html>