-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
109 lines (85 loc) · 2.76 KB
/
index.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<?xml version="1.0" encoding="UTF-8"?>
<head>
<meta charset="utf-8" />
<title> Auto-Titrate </title>
</head>
<body>
<h1>Auto-Titrate</h1>
<h2>WIP</h2>
<h3>Input Your Data</h3>
<!-- This form should ask for
concentration inputs and specify if the initial and added substance is a base or acid -->
<script src="math.js" src="document.js" type="text/javascript">
function titrate(){
var x = document.getElementById("form");
var inittype = x.elements[0].value;
var initial = Number(x.elements[1].value);
var initvol = Number(x.elements[2].value);
var addtype = x.elements[3].value;
var added = Number(x.elements[4].value);
var addvol = Number(x.elements[5].value);
var molinit = Number(initvol) * Number(initial);
var moladd = Number(addvol) * Number(added);
if (molinit < moladd){
moladd = moladd - molinit;
var newM = moladd / (addvol + initvol);
var pH;
if (addtype = "Base"){
pH = Math.log(((10 ^ (-14)) / (newM))) * (-1);
}
else {
pH = Math.log(newM) * (-1);
};
document.write("The concentration of " + addtype + " is " + newM + ". The pH is " + pH);
};
};
</script>
<div id="container">
<div id="main" role="main">
<form id="form" method=get>
Molar Concentration of Weak ___: [Base/Acid] <br />
<input type="text" name="inittype" value="Base"> <br />
Molarity: <input type="text" value="1.00" name="initial"><br />
<br />
Volume: <input type="text" value=".15" name="initvol"> (In liters)<br />
Molar Concentration of Strong ____ added: [Base/Acid]<br />
<input type="text" name="addtype" value="Base"><br />
Molarity: <input type="text" value="1.00" name="added"><br />
Volume: <input type="text" value=".15" name="addvol"> (In liters)<br />
[Ka/Kb]: <input type="text" value="0.001" name="constant">
</form>
<button onclick=titrate()> Titrate! </button>
<p> <span id="display"> </span> </p>
</div>
</div>
<!--
<script>
var x = document.getElementById("form");
var inittype = x.elements[0].value;
var initial = Number(x.elements[1].value);
var initvol = Number(x.elements[2].value);
var addtype = x.elements[3].value;
var added = Number(x.elements[4].value);
var addvol = Number(x.elements[5].value);
var molinit = Number(initvol) * Number(initial);
var moladd = Number(addvol) * Number(added);
if (molinit < moladd){
moladd = moladd - molinit;
var newM = moladd / (addvol + initvol);
var pH;
if (addtype = "Base"){
pH = Math.log(((10 ^ (-14)) / (newM))) * (-1);
}
}
else {
pH = Math.log(newM) * (-1);
}
document.write("The concentration of " + addtype + " is " + newM + ". The pH is " + pH)
-->
<script>
document.write(titrate())
</script>
</body>
</html>