您的软件和代码将是安全的,由于它们不会分发给终极用户
您的软件将很随意马虎与您的网站集成
先容
次氯酸钠溶液广泛用于家庭照顾护士,拍浮水消毒,家禽生产厂等。

它最广为人知的商品名称是Clorox。
许多小型工厂购买散装的浓缩溶液进行稀释和包装。
该打算器用于供应稀释的在线打算。
利用此打算器:确定您要产生的浓度,例如4%w/w
获取您拥有的储备溶液的浓度。
转到在线页面进行打算在线打算器
输入您的值,然后按打算
在线打算器将利用AJAX,因此页面将显示结果而无需重新加载。
所有输入数据将被发送到PHP脚本进行打算。
兴趣点:本文谈论以下技能:
如何构建可以在免费托管上运行的大略在线软件。
大略植入ajax
在PC上测试软件
托管哀求:
免费或付费托管帐户
该软件不须要数据库
托管应支持PHP。
为什么要利用PHP?
纵然是免费操持,它也是网络做事器上可用的最多做事器端脚本
它可以在Windows和Unix做事器上运行
在本地测试您的代码要在本地测试代码,您将须要具有PHP支持的Web做事器。
默认情形下,一些易于利用的支持PHP的做事器的列表。
统一做事器零:统一零重新核阅了Apache,MySQL,PHP和Perl的可移植性。它具有电源完备掌握面板
XAMPP:这是一个非常常见的基于Apache的Web做事器,具有PHP支持
Server2Go:具有PHP支持的基于Apache的便携式Web做事器。它可以在CD上运行
运用做事
USBWeb做事器
WampServer
您该当通过其他软件添加PHP支持的一些易于利用的做事器列表。
小型HTTP做事器,轻巧,功能强大,多功能的Web做事器。
IIS:IIS是在Windows中内置的,用于添加PHP支持,只需下载PHPforIIs并运行它即可
该运用程序如何事情?该运用取决于不同单位的浓度表和次氯酸钠溶液的密度。对付每个浓度,它还包含过量的氢氧化钠。
以将8%w/w的溶液稀释为4%的溶液所需的水量为例。
我们在表中搜索输入和输出氯的重量百分比和密度。
如果没有找到浓度,我们将根据最近的浓度进行打算
//This function will search for a given concentration //$var: value to be searched//$field:unit of the value function searchit($var, $field){ global $hypochlorite_table; //array contains the data table of chlorine concentrations //and density and reqiured sodium hydroxide global $precision; //precision for each field in the $hypochlorite_table array $var=round($var,$precision[$field]); if ( is_numeric ( $var )) $var = (trim($var) == '')? 0 :$var; else $var = 0; for ($index = 0; $index < count($hypochlorite_table); $index++) { if($var == $hypochlorite_table[$index][$field]){ return outputrow($index); }elseif($var < $hypochlorite_table[$index][$field]){ if(!$index) return outputrow($index); $delta = ($var-$hypochlorite_table[$index-1][$field])/($hypochlorite_table[$index][$field]-$hypochlorite_table[$index-1][$field]); return outputrow($index,$delta); } } return false;}function outputfield($field,&$row,$index,$delta=0){ global $hypochlorite_table,$precision; if($delta==0){ $row[$field]= round($hypochlorite_table[$index][$field], $precision[$field]); }else{ $row[$field]=round( $hypochlorite_table[$index-1][$field] + $delta($hypochlorite_table[$index][$field] - $hypochlorite_table[$index-1][$field]) , $precision[$field]); }}function outputrow($index,$delta=0){ $row=array(); outputfield(ClWV ,$row,$index,$delta); outputfield(d ,$row,$index,$delta); outputfield(dChange ,$row,$index,$delta); outputfield(ClWW ,$row,$index,$delta); outputfield(ClDegrees,$row,$index,$delta); outputfield(NaOClWV ,$row,$index,$delta); outputfield(NaOClWW ,$row,$index,$delta); outputfield(NaOH ,$row,$index,$delta); outputfield(dNone ,$row,$index,$delta); return $row;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253复制代码类型:[php]
听力是桌子的一部分
将表数据存储在数组中:
有3个数据字段,其他字段为打算字段。
我将数据字段存储在数组中
$hypochlorite_table =array(array(00.0, 1.001, 0.012),array(01.0, 1.020, 0.064),array(01.5, 1.027, 0.053),array(02.0, 1.034, 0.050),array(02.1, 1.035, 0.049),array(02.5, 1.041, 0.044),array(02.6, 1.043, 0.041),........</pre lang="php">12345678910复制代码类型:[php]
我定义字段常量
$fields=array(0=>'ClWV', //Cl(%w/v): weight of chlorine in 100 ml of the solution1=>'d', //Specific Gravity of Sodium Hypochlorite solution that //contains default required excess of Sodium Hydroxide2=>'dChange', //Specific Gravity change when adding 1% NaOH3=>'ClWW', //Cl%= ClWV /d4=>'ClDegrees', //°Cl Chlorometric Degrees = = 3.2 ClWV5=>'NaOClWV', //NaOCl% w/v: weight of Sodium Hypochlorite in 100 ml of the solution 6=>'NaOClWW', //NaOCl%: weight of Sodium Hypochlorite in 100 g of the solution 7=>'NaOH', //NaOH%: Default required excess of Sodium Hydroxide for //this concentration of hypochlorite=0.25+ClWW0.75/168=>'dNone' //Specific gravity of Sodium Hypochlorite solution that //does not contain any excess of Sodium Hydroxide );foreach ($fields as $key => $value) define($value,$key);12345678910111213141516复制代码类型:[php]
然后,我将打算出的字段存储在数组中以便于搜索。
我写了一个HTML页面,它将作为运用程序的界面
利用AJAX调用PHP数据用户填写表单并按打算按钮后,它将调用AjaxRefresh函数。
此功能将实行以下操作
将所有表单数据存储在字符串中
创建XMLHttpRequest工具
创建一个将处理AJAX相应的函数
打开XMLHttpRequest工具并发送数据
function AjaxRefresh(){var q = 'ajax.php' + '?id=' + '&CIn=' + CIn.value + '&COut=' + COut.value + '&dIn=' + dIn.value + '&lang=' + lang.value + '&NaOHIn=' + NaOHIn.value + '&QOut=' + QOut.value + '&UnitIn=' + UnitIn.value + '&UnitInAr=' + UnitInAr.value + '&UnitOut=' + UnitOut.value + '&UnitOutAr=' + UnitOutAr.value +'&UnitQOut=' + UnitQOut.value +'&UnitQOutAr=' + UnitQOutAr.value ;var xmlhttp=new XMLHttpRequest();xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState===4 && xmlhttp.status===200) var pairs = xmlhttp.responseText.split('&'); for(i=0;i<pairs.length;i++){ var pair = pairs[i].split('='); var element = document.getElementById(pair[0]); if(element===null){ }else{ try{element.innerHTML = pair[1].trim();}catch(e){}; try{element.value = pair[1].trim();}catch(e){}; }; };};xmlhttp.open("GET",q,true);xmlhttp.send();}123456789101112131415161718192021222324252627282930313233复制代码类型:[php]
PHP脚本将发送HTML元素ID及其新值