我们想创建一个页面,您可以在其中选择可以用太阳能抵消的台式电器,我们提供满足他们需求的系统。这应该很简单,但我找不到有效地完成所有事情的最佳方法。
他们选择他们想用太阳能代替的东西,我们只捕获他们选择的项目的瓦数并求和。然后使用 if-else 语句显示产生必要能量的系统。
总和正在屏幕上工作,但 if else 语句无法访问,如果您选择所有 4 个设备,则数学会将数字四舍五入为重复数字。如果你能帮助我指出正确的方向,我确定我的论点分组在错误的标题下。
接下来是如何调用具有正确太阳能系统规范的 PDF 或网页(2、3、4... 模块系统)
<script>
function update(form) {
var total = 0;
var el;
for (var i=0, iLen=form.elements.length; i<iLen; i++) {
el = form.elements[i];
if (el.type == 'checkbox') {
total += el.checked? +el.value : 0;
}
}
form.total.value = total;
}
</script>
<form onclick="update(this);">
<table width="550" border="1">
<tr>
<th scope="col">Appliance</th>
<th scope="col">Watts / Mo</th>
<th scope="col">Offset This?</th>
</tr>
<tr>
<th scope="row">bose wave</th>
<td>8.76</td>
<td><input name="Bose Wave" type="checkbox" value="8.76"></td>
</tr>
<tr>
<th scope="row">Cable/Sat Box</th>
<td>32.85</td>
<td><input name="Cable/Sat box" type="checkbox" value="32.85"></td>
</tr>
<tr>
<th scope="row">Desktop Computer/Monitor</th>
<td>142.35</td>
<td><input name="Desktop Computer/Monitor" type="checkbox" value="142.35"></td>
</tr>
<tr>
<th scope="row">xBox 360</th>
<td>14.65</td>
<td><input name="xBox 360" type="checkbox" value="14.65"></td>
</tr>
<tr>
<th scope="row">Total</th>
<td colspan="2"><input type="text" name="total" readonly></td>
</tr>
</table>
<script>
var x=""
var total=totaloffset
if (total < 75)
{
x="use 2 module system";
}else if (total < 115){
x="use 3 module system";
}else if (total < 160){
x="use 4 module system";
}else if (totalOffset < 188){
trace ("use 5 module system");
}else if (totalOffset < 227){
trace ("use 6 module system");
}else if (totalOffset < 265){
trace ("use 7 module system");
}else if (totalOffset < 303){
trace ("use 8 module system");
}else if (totalOffset < 341){
trace ("use 9 module system");
}else if (totalOffset < 379){
trace ("use 10 module system");
}else {
x="use 11+ module system, Contact us for sizing";
}
document.getElementById("Total").innerHTML+=val;
</script>
</form>
<script type="text/javascript">
function MM_changeProp(Total,x,theProp,theValue) { //v9.0
var obj = null; with (document){ if (getElementById)
obj = getElementById(Total); }
if (obj){
if (theValue == true || theValue == false)
eval("obj.style."+theProp+"="+theValue);
else eval("obj.style."+theProp+"='"+theValue+"'"); }}
</script>
<script type="text/javascript">
function insertText(val,total){
document.getElementById(total).innerHTML+=val;
}
</script>
<script>
function update(form) {
var total = 0;
var el;
var totalOffset;
for (var i=0, iLen=form.elements.length; i<iLen; i++) {
el = form.elements[i];
if (el.type == 'checkbox') {
total += el.checked? +el.value : 0;
}
if (total < 75) {
trace("use 2 module system");
}else if (total < 115)
trace("use 3 module system");
}else if (totalOffset < 160)
trace ("use 4 module system");
}else if (totalOffset < 188)
trace ("use 5 module system");
}else if (totalOffset < 227)
trace ("use 6 module system");
}else if (totalOffset < 265)
trace ("use 7 module system");
}else if (totalOffset < 303)
trace ("use 8 module system");
}else if (totalOffset < 341)
trace ("use 9 module system");
}else if (totalOffset < 379)
trace ("use 10 module system");
}else if 0
trace ("use 11+ module system, Contact us for sizing)
</script>
<br />
<br />
<br />
</p>
</form>