尝试为所需的放大器创建JavaScript计算器

时间:2016-02-19 19:21:54

标签: javascript calculator nan

您好我正在尝试制作一个计算器,以便人们可以知道在工作现场需要多少瓦特,电流和电压。我正在尝试制作一个他们可以填写的表格,这样他们就可以在工作现场输入他们拥有的每种类型的设备。我拥有我想要的一切,但是当我点击计算时,答案是" NaN"。我感谢你的帮助。



<form><table width="960">
<tr><td colspan="4" bgcolor="#CCCCCC"><h2>HD-CVI Cameras</h2></td></tr>
<tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
	<tr><td>HAC-HDBW2220R-Z:</td><td>DC 12V</td><td>&lt; 0.7 Amps (When IRs cut on)</td><td><input type="text" name="valueOne"   value="0" id="valueOne"></td></tr> 
    <tr><td>HAC-HFW2220R-Z:</td><td>DC 12V</td><td>&lt; 0.7 Amps (When IRs cut on)</td><td><input type="text" name="valueTwo"   value="0" id="valueTwo"></td></tr>
    <tr><td>DH-IDF-480B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueThree" value="0" id="valueThree"> <br></td></tr> 
    <tr><td>DH-IBF-680B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueFour" value="0" id="valueFour"> <br></td></tr> 
    <tr><td>DH-IBV-780B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueFive" value="0" id="valueFive"> <br></td></tr> 
    <tr><td>DH-IDV-580B(W)-MZ:</td><td>DC 12V</td><td>&lt; 1.0 Amps (/w Motorized Lens)</td><td><input type="text" name="valueSix" value="0" id="valueSix"> <br></td></tr> 
    <tr><td>DH-IDV-580B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueTwentyfour" value="0" id="valueTwentyfour"> <br></td></tr> 
    <tr><td>DH-IDF-480B(W):</td><td>DC 12V</td><td>&lt; 0.45 Amps (When IRs cut on)</td><td><input type="text" name="valueSeven" value="0" id="valueSeven"> <br></td></tr> 
    <tr><td>DH-IBF-680B(W):</td><td>DC 12V</td><td>&lt; 0.45 Amps (When IRs cut on)</td><td><input type="text" name="valueEight" value="0" id="valueEight"> <br></td></tr> 
    <tr><td>DH-IV-980W:</td><td>DC 12V</td><td>&lt; 0.45 Amps (When IRs cut on)</td><td><input type="text" name="valueNine" value="0" id="valueNine"> <br></td></tr>  
    <tr><td colspan="4" bgcolor="#CCCCCC"><h2>HD-CVI PTZ Cameras</h2></td></tr>
    <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
    <tr><td>SD42212I-HC:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTen" value="0" id="valueTen"> <br></td></tr> 
    <tr><td>SD59220I-HC:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueEleven" value="0" id="valueEleven"> <br></td></tr>
    <tr><td colspan="4" bgcolor="#CCCCCC"><h2>Uniview IPC Cameras</h2></td></tr>
    <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
    <tr><td>IPC542E-DUC:</td><td>AC 24V / DC 12V / PoE</td><td>&lt; 0.60 Amps (When ICR Switches)</td><td><input type="text" name="valueTwelve" value="0" id="valueTwelve"> <br></td></tr> 
    <tr><td>IPC3612ER3-PF28(36):</td><td>DC 12V / PoE</td><td>&lt; .47 Amps (When IRs cut on)</td><td><input type="text" name="valueThirteen" value="0" id="valueThirteen"> <br></td></tr> 
    <tr><td>IPC3232ER-VS(DV):</td><td>DC 12V / PoE</td><td>&lt; 0.65 Amps (When IRs cut on)</td><td><input type="text" name="valueFourteen" value="0" id="valueFourteen"> <br></td></tr> 
    <tr><td>IPC2122SR3-PF36:</td><td>DC 12V / PoE</td><td>&lt; 0.55 Amps (When IRs cut on)</td><td><input type="text" name="valueFifteen" value="0" id="valueFifteen"> <br></td></tr> 
    <tr><td>IPC242E-IR-Z-IN:</td><td>DC 12V / PoE</td><td>&lt; 1.00 Amps (When IRs cut on)</td><td><input type="text" name="valueSixteen" value="0" id="valueSixteen"> <br></td></tr> 
    <tr><td>IPC242ER5-DL:</td><td>DC 12V / PoE</td><td>&lt; 1.00 Amps (When IRs cut on)</td><td><input type="text" name="valueEightteen" value="0" id="valueEightteen"> <br></td></tr> 
    <tr><td>IPC3234SR-DVZ28:</td><td>DC 12V / PoE</td><td>&lt; 1.50 Amps (/w Motorized Lens)</td><td><input type="text" name="valueNineteen" value="0" id="valueNineteen"> <br></td></tr> 
    <tr><td>IPC2124SR3-PF36:</td><td>DC 12V / PoE</td><td>&lt; 0.55 Amps (When IRs cut on)</td><td><input type="text" name="valueTwenty" value="0" id="valueTwenty"> <br></td></tr>
    <tr><td>IPC2324EBR-DPZ28:</td><td>DC 12V / PoE</td><td>&lt; 1.50 Amps (/w Motorized Lens)</td><td><input type="text" name="valueTwentyfive" value="0" id="valueTwentyfive"> <br></td></tr>
    <tr><td colspan="4" bgcolor="#CCCCCC"><h2>Uniview PTZ Cameras</h2></td></tr>
    <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr> 
    <tr><td>IPC642E-X30N:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTwentyone" value="0" id="valueTwentyone"> <br></td></tr> 
    <tr><td>IPC6222ER-X20(X30):</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTwentytwo" value="0" id="valueTwentytwo"> <br></td></tr> 
    <tr><td>IPC6242SL-X22:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTwentythree" value="0" id="valueTwentythree"> <br></td></tr>
 
<tr><td height="10"></td></tr>
<tr><td colspan="3"></td><td><div id="result"></div></td></tr>
<tr><td height="10"></td></tr>
    <tr><td colspan="3"></td><td><input type="button" value="Calculate power needed!"  onclick="javascript:myCalc(document.getElementById('valueOne').value, document.getElementById('valueTwo').value, document.getElementById('valueThree').value, document.getElementById('valueFour').value), document.getElementById('valueFive').value, document.getElementById('valueSix').value, document.getElementById('valueSeven').value, document.getElementById('valueEight').value, document.getElementById('valueNine').value, document.getElementById('valueTen').value, document.getElementById('valueEleven').value, document.getElementById('valueTwelve').value, document.getElementById('valueThirteen').value, document.getElementById('valueFourteen').value, document.getElementById('valueFifteen').value, document.getElementById('valueSixteen').value, document.getElementById('valueSeventeen').value, document.getElementById('valueEightteen').value, document.getElementById('valueNineteen').value, document.getElementById('valueTwenty').value, document.getElementById('valueTwentyone').value, document.getElementById('valueTwentytwo').value, document.getElementById('valueTwentythree').value, document.getElementById('valueTwentyfour').value, document.getElementById('valueTwentyfive').value">
</form></td></tr>
    </table> 
<script>
 
function myCalc(valueOne, valueTwo, valueThree, valueFour ,valueFive, valueSix, valueSeven, valueEight, valueNine, valueTen, valueEleven, valueTwelve, valueThirteen, valueFourteen, valueFifteen, valueSixteen, valueSeventeen, valueEightteen, valueNineteen, valueTwenty, valueTwentyone, valueTwentytwo, valueTwentythree, valueTwentyfour, valueTwentyfive)
{
    if (valueOne == 0) {
        document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueFour)*.5) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
    } else if (valueTwo == 0) {
        document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueOne)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueFour)*.5) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
    } else if (valueThree == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueOne)*.70) + (parseFloat(valueFour)*.5) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
    } else if (valueFour == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueFive == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFour)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueSix == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueFour)*.5) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueSeven == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueFour)*.5) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueEight == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueFour)*.50) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueNine == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueFour)*.5) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueFour)*.50)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueEleven == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwelve == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueFour)*.50)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueThirteen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueFour)*.50) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueFourteen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFour)*.50) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueFifteen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFour)*.50) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueSixteen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueFour)*.5) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueEightteen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueFour)*.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueNineteen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueFour)*.50) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwenty == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwentyone == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwentytwo == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwentythree == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwentyfour == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
	} else if (valueTwentyfive == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueSeventeen)*1.00) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyFour)*.50));
	} else if (valueSeventeen == 0)  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueFour)*.50) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50));
		} else  {
		document.getElementById("result").innerHTML = 'Power Needed: '+ ((parseFloat(valueTwo)*.70) + (parseFloat(valueThree)*.5) + (parseFloat(valueOne)*.70) + (parseFloat(valueFive)*.5) + (parseFloat(valueSix)*1.0) + (parseFloat(valueTwentyfour)*.5) + (parseFloat(valueSeven)*.45) + (parseFloat(valueEight)*.45) + (parseFloat(valueNine)*.45) + (parseFloat(valueTwelve)*.60)+ (parseFloat(valueThirteen)*.47) +(parseFloat(valueFourteen)*.65) + (parseFloat(valueFifteen)*.55) + (parseFloat(valueSixteen)*1.00) + (parseFloat(valueFour)*.50) + (parseFloat(valueEightteen)*1.50) + (parseFloat(valueNineteen)*.55) + (parseFloat(valueTwentyfive)*1.50))		
	}
}
</script>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

在您的onclick中,您在valueFour之后关闭了括号。将其移至onclick的末尾。

此外,没有ID为valueSeventeen的输入。

修复那些使它适合我。

答案 1 :(得分:0)

这个设计让我哭...但这里是固定的( - )解决方案......

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <form>
        <table width="960">
            <tr><td colspan="4" bgcolor="#CCCCCC"><h2>HD-CVI Cameras</h2></td></tr>
            <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
            <tr><td>HAC-HDBW2220R-Z:</td><td>DC 12V</td><td>&lt; 0.7 Amps (When IRs cut on)</td><td><input type="text" name="valueOne" value="0" id="valueOne"></td></tr>
            <tr><td>HAC-HFW2220R-Z:</td><td>DC 12V</td><td>&lt; 0.7 Amps (When IRs cut on)</td><td><input type="text" name="valueTwo" value="0" id="valueTwo"></td></tr>
            <tr><td>DH-IDF-480B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueThree" value="0" id="valueThree"> <br></td></tr>
            <tr><td>DH-IBF-680B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueFour" value="0" id="valueFour"> <br></td></tr>
            <tr><td>DH-IBV-780B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueFive" value="0" id="valueFive"> <br></td></tr>
            <tr><td>DH-IDV-580B(W)-MZ:</td><td>DC 12V</td><td>&lt; 1.0 Amps (/w Motorized Lens)</td><td><input type="text" name="valueSix" value="0" id="valueSix"> <br></td></tr>
            <tr><td>DH-IDV-580B(W)(ZA)-V2:</td><td>DC 12V</td><td>&lt; 0.5 Amps (When IRs cut on)</td><td><input type="text" name="valueTwentyfour" value="0" id="valueTwentyfour"> <br></td></tr>
            <tr><td>DH-IDF-480B(W):</td><td>DC 12V</td><td>&lt; 0.45 Amps (When IRs cut on)</td><td><input type="text" name="valueSeven" value="0" id="valueSeven"> <br></td></tr>
            <tr><td>DH-IBF-680B(W):</td><td>DC 12V</td><td>&lt; 0.45 Amps (When IRs cut on)</td><td><input type="text" name="valueEight" value="0" id="valueEight"> <br></td></tr>
            <tr><td>DH-IV-980W:</td><td>DC 12V</td><td>&lt; 0.45 Amps (When IRs cut on)</td><td><input type="text" name="valueNine" value="0" id="valueNine"> <br></td></tr>
            <tr><td colspan="4" bgcolor="#CCCCCC"><h2>HD-CVI PTZ Cameras</h2></td></tr>
            <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
            <tr><td>SD42212I-HC:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTen" value="0" id="valueTen"> <br></td></tr>
            <tr><td>SD59220I-HC:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueEleven" value="0" id="valueEleven"> <br></td></tr>
            <tr><td colspan="4" bgcolor="#CCCCCC"><h2>Uniview IPC Cameras</h2></td></tr>
            <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
            <tr><td>IPC542E-DUC:</td><td>AC 24V / DC 12V / PoE</td><td>&lt; 0.60 Amps (When ICR Switches)</td><td><input type="text" name="valueTwelve" value="0" id="valueTwelve"> <br></td></tr>
            <tr><td>IPC3612ER3-PF28(36):</td><td>DC 12V / PoE</td><td>&lt; .47 Amps (When IRs cut on)</td><td><input type="text" name="valueThirteen" value="0" id="valueThirteen"> <br></td></tr>
            <tr><td>IPC3232ER-VS(DV):</td><td>DC 12V / PoE</td><td>&lt; 0.65 Amps (When IRs cut on)</td><td><input type="text" name="valueFourteen" value="0" id="valueFourteen"> <br></td></tr>
            <tr><td>IPC2122SR3-PF36:</td><td>DC 12V / PoE</td><td>&lt; 0.55 Amps (When IRs cut on)</td><td><input type="text" name="valueFifteen" value="0" id="valueFifteen"> <br></td></tr>
            <tr><td>IPC242E-IR-Z-IN:</td><td>DC 12V / PoE</td><td>&lt; 1.00 Amps (When IRs cut on)</td><td><input type="text" name="valueSixteen" value="0" id="valueSixteen"> <br></td></tr>
            <tr><td>IPC242ER5-DL:</td><td>DC 12V / PoE</td><td>&lt; 1.00 Amps (When IRs cut on)</td><td><input type="text" name="valueEightteen" value="0" id="valueEightteen"> <br></td></tr>
            <tr><td>IPC3234SR-DVZ28:</td><td>DC 12V / PoE</td><td>&lt; 1.50 Amps (/w Motorized Lens)</td><td><input type="text" name="valueNineteen" value="0" id="valueNineteen"> <br></td></tr>
            <tr><td>IPC2124SR3-PF36:</td><td>DC 12V / PoE</td><td>&lt; 0.55 Amps (When IRs cut on)</td><td><input type="text" name="valueTwenty" value="0" id="valueTwenty"> <br></td></tr>
            <tr><td>IPC2324EBR-DPZ28:</td><td>DC 12V / PoE</td><td>&lt; 1.50 Amps (/w Motorized Lens)</td><td><input type="text" name="valueTwentyfive" value="0" id="valueTwentyfive"> <br></td></tr>
            <tr><td colspan="4" bgcolor="#CCCCCC"><h2>Uniview PTZ Cameras</h2></td></tr>
            <tr><td bgcolor="#eaeaea"><b>Model</b></td><td bgcolor="#eaeaea"><b>Voltage type</b></td><td bgcolor="#eaeaea"><b>Amps</b></td><td bgcolor="#eaeaea"><b>Amount on Job</b></td></tr>
            <tr><td>IPC642E-X30N:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTwentyone" value="0" id="valueTwentyone"> <br></td></tr>
            <tr><td>IPC6222ER-X20(X30):</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTwentytwo" value="0" id="valueTwentytwo"> <br></td></tr>
            <tr><td>IPC6242SL-X22:</td><td>AC 24V</td><td>3.0 Amps</td><td><input type="text" name="valueTwentythree" value="0" id="valueTwentythree"> <br></td></tr>

            <tr><td height="10"></td></tr>
            <tr><td colspan="3"></td><td><div id="result"></div></td></tr>
            <tr><td height="10"></td></tr>
            <tr>
                <td colspan="3"></td>
                <td>
                    <input type="button" value="Calculate power needed!" onclick="javascript:myCalc();">
                </td>
            </tr>
        </table>
    </form>
    <script>

        function myCalc() {
            var valueOne = document.getElementById('valueOne').value;
            var valueTwo = document.getElementById('valueTwo').value;
            var valueThree = document.getElementById('valueThree').value;
            var valueFour = document.getElementById('valueFour').value;
            var valueFive = document.getElementById('valueFive').value;
            var valueSix = document.getElementById('valueSix').value;
            var valueSeven = document.getElementById('valueSeven').value;
            var valueEight = document.getElementById('valueEight').value;
            var valueNine = document.getElementById('valueNine').value;
            var valueTen = document.getElementById('valueTen').value;
            var valueEleven = document.getElementById('valueEleven').value;
            var valueTwelve = document.getElementById('valueTwelve').value;
            var valueThirteen = document.getElementById('valueThirteen').value;
            var valueFourteen = document.getElementById('valueFourteen').value;
            var valueFifteen = document.getElementById('valueFifteen').value;
            var valueSixteen = document.getElementById('valueSixteen').value;
            var valueSeventeen = 0;//document.getElementById('valueSeventeen').value;
            var valueEightteen = document.getElementById('valueEightteen').value;
            var valueNineteen = document.getElementById('valueNineteen').value;
            var valueTwenty = document.getElementById('valueTwenty').value;
            var valueTwentyone = document.getElementById('valueTwentyone').value;
            var valueTwentytwo = document.getElementById('valueTwentytwo').value;
            var valueTwentythree = document.getElementById('valueTwentythree').value;
            var valueTwentyfour = document.getElementById('valueTwentyfour').value;
            var valueTwentyfive = document.getElementById('valueTwentyfive').value;
            var result =
                (isNaN(valueOne) ? 0 : parseFloat(valueOne) * .7) +
                (isNaN(valueTwo) ? 0 : parseFloat(valueTwo) * .7) +
                (isNaN(valueThree) ? 0 : parseFloat(valueThree) * .5) +
                (isNaN(valueFour) ? 0 : parseFloat(valueFour) * .5) +
                (isNaN(valueFive) ? 0 : parseFloat(valueFive) * .5) +
                (isNaN(valueSix) ? 0 : parseFloat(valueSix)) +
                (isNaN(valueSeven) ? 0 : parseFloat(valueSeven) * .45) +
                (isNaN(valueEight) ? 0 : parseFloat(valueEight) * .45) +
                (isNaN(valueNine) ? 0 : parseFloat(valueNine) * .45) +
                (isNaN(valueTen) ? 0 : parseFloat(valueTen) * 3) +
                (isNaN(valueEleven) ? 0 : parseFloat(valueEleven) * 3) +
                (isNaN(valueTwelve) ? 0 : parseFloat(valueTwelve) * .6) +
                (isNaN(valueThirteen) ? 0 : parseFloat(valueThirteen) * .47) +
                (isNaN(valueFourteen) ? 0 : parseFloat(valueFourteen) * .65) +
                (isNaN(valueFifteen) ? 0 : parseFloat(valueFifteen) * .55) +
                (isNaN(valueSixteen) ? 0 : parseFloat(valueSixteen)) +
                (isNaN(valueSeventeen) ? 0 : parseFloat(valueSeventeen)) +
                (isNaN(valueEightteen) ? 0 : parseFloat(valueEightteen)) +
                (isNaN(valueNineteen) ? 0 : parseFloat(valueNineteen) * 1.5) +
                (isNaN(valueTwenty) ? 0 : parseFloat(valueTwenty) * .55) +
                (isNaN(valueTwentyone) ? 0 : parseFloat(valueTwentyone) * 3) +
                (isNaN(valueTwentytwo) ? 0 : parseFloat(valueTwentytwo) * 3) +
                (isNaN(valueTwentythree) ? 0 : parseFloat(valueTwentythree) * 3) +
                (isNaN(valueTwentyfour) ? 0 : parseFloat(valueTwentyfour) * .5) +
                (isNaN(valueTwentyfive) ? 0 : parseFloat(valueTwentyfive) * 1.5);
            document.getElementById("result").innerHTML = 'Power Needed: ' + result + ' amps.';
        }
    </script>
</body>
</html>

注意:没有&#34; valueSeventeen&#34;文本框。