URCENIE HODNOTY ODPORU

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

156
p156.html / p156.zip
Urcuje hodnoty odporov na zaklade farebnych pasikov.
4572b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<HTML> <HEAD> <TITLE>JavaScript DESTINATION - P156</TITLE> <SCRIPT LANGUAGE="JavaScript1.1"> <!-- var multiplier = new Array() multiplier[0] = 0 multiplier[1] = 1 multiplier[2] = 2 multiplier[3] = 3 multiplier[4] = 4 multiplier[5] = 5 multiplier[6] = 6 multiplier[7] = 7 multiplier[8] = 8 multiplier[9] = 9 multiplier[10] = -1 multiplier[11] = -2 var tolerance = new Array() tolerance[0] = "+/-5%" tolerance[1] = "+/-10%" tolerance[2] = "+/-20%" function format(ohmage) { if (ohmage >= 10e6) { ohmage /= 10e5 return "" + ohmage + " Mohmov" } else { if (ohmage >= 10e3) { ohmage /= 10e2 return "" + ohmage + " kohmov" } else { return "" + ohmage + " ohmov" } } } function calcOhms() { var form = document.forms[0] var d1 = form.tensSelect.selectedIndex var d2 = form.onesSelect.selectedIndex var m = form.multiplierSelect.selectedIndex var t = form.toleranceSelect.selectedIndex var ohmage = (d1 * 10) + d2 ohmage = eval("" + ohmage + "e" + multiplier[m]) ohmage = format(ohmage) var tol = tolerance[t] document.forms[1].result.value = ohmage + ", " + tol } var colorList = "cierna,modra,hneda,zlata,siva,zelena,ziadna,oranzova,cervena,strieborna,fialova,biela,zlta" var colorArray = colorList.split(",") var imageDB = new Array() for (i = 0; i < colorArray.length; i++) { imageDB[colorArray[i]] = new Image(21,182) imageDB[colorArray[i]].src = "images/r" + colorArray[i] + ".gif" } function setTens(choice) { var tensColor = choice.options[choice.selectedIndex].text document.tens.src = imageDB[tensColor].src calcOhms() } function setOnes(choice) { var onesColor = choice.options[choice.selectedIndex].text document.ones.src = imageDB[onesColor].src calcOhms() } function setMult(choice) { var multColor = choice.options[choice.selectedIndex].text document.mult.src = imageDB[multColor].src calcOhms() } function setTol(choice) { var tolColor = choice.options[choice.selectedIndex].text document.tol.src = imageDB[tolColor].src calcOhms() } function showIntro() { window.open("resintro.htm","","WIDTH=400,HEIGHT=260") } // --> </SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF" onLoad="calcOhms()"> <CENTER> <H3>Identifikacia hodnoty odporu podla farebnych pruzkov</H3> <FORM> <SELECT NAME="tensSelect" onChange="setTens(this)"> <OPTION SELECTED> cierna <OPTION> hneda <OPTION> cervena <OPTION> oranzova <OPTION> zlta <OPTION> zelena <OPTION> modra <OPTION> fialova <OPTION> siva <OPTION> biela </SELECT> <SELECT NAME="onesSelect" onChange="setOnes(this)"> <OPTION SELECTED> cierna <OPTION> hneda <OPTION> cervena <OPTION> oranzova <OPTION> zlta <OPTION> zelena <OPTION> modra <OPTION> fialova <OPTION> siva <OPTION> biela </SELECT> <SELECT NAME="multiplierSelect" onChange="setMult(this)"> <OPTION SELECTED> cierna <OPTION> hneda <OPTION> cervena <OPTION> oranzova <OPTION> zlta <OPTION> zelena <OPTION> modra <OPTION> fialova <OPTION> siva <OPTION> biela <OPTION> zlata <OPTION> strieborna </SELECT>&nbsp;&nbsp;&nbsp;&nbsp; <SELECT NAME="toleranceSelect" onChange="setTol(this)"> <OPTION SELECTED> zlata <OPTION> strieborna <OPTION> ziadna </SELECT> </FORM> <SCRIPT LANGUAGE="JavaScript1.1"> var form = document.forms[0] var tensDigit = form.tensSelect.selectedIndex var tensColor = form.tensSelect.options[tensDigit].text var onesDigit = form.onesSelect.selectedIndex var onesColor = form.onesSelect.options[onesDigit].text var multDigit = form.multiplierSelect.selectedIndex var multColor = form.multiplierSelect.options[multDigit].text var tolDigit = form.toleranceSelect.selectedIndex var tolColor = form.toleranceSelect.options[tolDigit].text var table ="<TABLE BORDER=0>" table += "<TR><TH ALIGN=middle>Hodnota odporu:</TH><TD ALIGN='middle'><FORM><INPUT TYPE='text' NAME='result' SIZE=20></FORM>" table +="</TD></TR><TR><TD COLSPAN=2>" table +="<IMG SRC='images/resleft.gif' WIDTH=127 HEIGHT=182>" + "<IMG SRC='images/r" + tensColor + ".gif' NAME='tens' WIDTH=21 HEIGHT=182>"+ "<IMG SRC='images/r" + onesColor + ".gif' NAME='ones' WIDTH=21 HEIGHT=182>"+ "<IMG SRC='images/r" + multColor + ".gif' NAME='mult' WIDTH=21 HEIGHT=182>"+ "<IMG SRC='images/spacer.gif' WIDTH=17 HEIGHT=182>"+ "<IMG SRC='images/r" + tolColor + ".gif' NAME='tol' WIDTH=21 HEIGHT=182>"+ "<IMG SRC='images/resright.gif' WIDTH=127 HEIGHT=182>" table += "</TD></TR></TABLE>" document.write(table) </SCRIPT> </BODY> </HTML>
[ Navrat / BACK ]