网页版 TCID50计算器
引用了 JQuery js库
界面如下:
![](https://img.haomeiwen.com/i20692894/95c2786f5b52ba22.png)
html代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tcid50-form-table-input</title>
<script src="./js/jquery-1.10.1.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
caption{
border: 3px;
font-size: 20px;
}
table{
margin: 0 auto;
text-align: center;
}
#head1{
font-size: 20px;
cellpadding: 12;
}
h2{
opacity:0.1
}
input{
width: 50px;
font-size: 20px;
background-color: #bfa;
}
#calc2{
background-color: #00A2E6;
font-size: 40px;
}
#calc{
font-size: 40px;
}
#out2{
background-color: lightgoldenrodyellow ;
font-size: 40px;
}
</style>
</head>
<body>
<table id= "mytable" border="1" cellspacing="4" cellpadding="8">
<caption>实验模块</caption>
<tr id=head1>
<th> </th>
<th>一</th>
<th>二</th>
<th>三</th>
<th>四</th>
<th>五</th>
<th>六</th>
<th>七</th>
<th>八</th>
</tr>
<tr id="input_eight">
<th>输入</th>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
<td><input type="number" name="cpe" id="" value="" /></td>
</tr>
<tr>
<th>计算结果</th>
<td id="out2" value="123" colspan="5">123</td>
<td id="calc2" colspan="3" style="padding: 0;">
<button onclick="onSubmit()" style="font-size: 40px;margin:0; width:240px;height:100px; ">计算</button>
</td>
</tr>
</table>
<br>
<h2 >版权:Copyright 2021</h2>
<script type="text/javascript">
$(function () {
console.log("ready执行");
});
function onload(){
console.log("你好")
}
function onSubmit(){
var $mytable = $('#input_eight')
var $txt = $("[name='cpe']")
var res = new Array();
$txt.each(function(){
res.push($(this).val());
})
// alert(res)
console.log(res)
console.log(typeof(res))
var cpe_a = []
cpe_a = res
console.log(typeof(cpe_a))
a = cpe_a
b=[],
a_acc = [], //# 各CPE累积孔数
b_acc = [], //# 各非CPE累积孔数
ab_acc = [], //# 各孔累积和
a_ratio = []; // # CPE累积孔数占比
var gd50z=0.0,
gd50=0.0,
d50=0.0,
s=0.0,
tcid50j=0.0;
for(var i =0;i<8;i++){
b[i]=8-parseInt(a[i]);
}
console.log(b);
// 计算CPE累积孔数,
s = 0.0;
a_=a.reverse()
for(i=0;i<8;i++){
s = parseInt(s) + parseInt(a[i]);
a_acc[i]=s;
}
s = s + i;
a_acc=a_acc.reverse();
console.log(a_acc);
a.reverse();
//计算非CPE累积孔数
s = 0
for(i=0;i<8;i++){
s = parseInt(s) + parseInt(b[i]);
b_acc[i]=s;
}
console.log(b_acc);
s=0;
// 计算总累积孔数
for(i=0;i<8;i++){
ab_acc[i]=a_acc[i]+b_acc[i];
}
console.log(ab_acc);
// 计算各CPE累积孔数 占 总累积孔数(CPE累积和非CPE累积)的 比例
for(i=0;i<8;i++){
a_ratio[i]=parseFloat(a_acc[i])/parseFloat(ab_acc[i]);
}
console.log("\n CPE累积占比为:\n " + a_ratio);
// 寻找大于等于最接近于50%的稀释度 占率
a_ratio.reverse();
for(i=0;i<8;i++){
if (parseFloat(a_ratio[i]) >= 0.5){
gd50z = parseFloat(a_ratio[i]);
gd50 = 8 - i - 1;
break;
}
}
console.log("gd50z:"+gd50z);
console.log("a_ra: "+a_ratio);
// 寻找小于50%且最近于50%的稀释度 占率
a_ratio.reverse();
for(i=0;i<8;i++){
if (a_ratio[i] < 0.5){
console.log("现在a-ra为: "+ a_ratio[i] +" i为: " +i);
d50=a_ratio[i];
break;
}
}
console.log("d50: "+ d50);
// 计算距离
s = (gd50z - 0.5) / (gd50z - d50)
console.log("gd50, gd50z分别为: " + gd50, gd50z);
console.log("距离为: "+s);
// 计算lg(TCID50) =
this.tcid50 = -(gd50 + 1 + s)
tcid_out = this.tcid50
tcid_out = tcid_out.toFixed(6);
console.log(this.tcid50);
// var name = $tr.children('td:first').html()
var out = document.getElementById('out2');
out.innerText = tcid_out.toString()
}
</script>
</body>
</html>
网友评论