<script>
var tolerance = new Array()
tolerance[0] = "Gold"
tolerance[1] = "Silver"
tolerance[2] = "Black"
var code = new Array()
code[0] = "Black"
code[1] = "Brown"
code[2] = "Red"
code[3] = "Orange"
code[4] = "Yellow"
code[5] = "Green"
code[6] = "Blue"
code[7] = "Violet"
code[8] = "Grey"
code[9] = "White"
// pre-load all color images into image cache
var colorList = "Black,Blue,Brown,Gold,Grey,Green,None,Orange,Red,Silver,Violet,White,Yellow"
var colorArray = colorList.split(",")
var imageDB = new Array()
for (i = 0; i < colorArray.length; i++) {
imageDB[colorArray[i]] = new Image(21,128)
imageDB[colorArray[i]].src = "images/i" + colorArray[i] + ".gif"
}
// calculate and display colours
function calccode() {
var form = document.forms.res;
with(Math){
value=calculatemult3(form.inductancemult.selectedIndex,form.inductance.value);
//convert to microhenrys
value *=1000000;
if(value<1){
alert("The inductance must be at least 1 . The calculator will be upgraded soon to handle inductance less than this.");}
else{
tol=form.tolerance.selectedIndex;
mult=0;
while(value>=100)
{value /=10;
mult++;}
value=String(round(value));
if(value.length<2)
{value=0 + value;}
dig1=value.charAt(0);
dig2=value.charAt(1);
form.band1.value = code[dig1];
form.band2.value = code[dig2];
form.band3.value = code[mult];
form.tolband.value = tolerance[tol];
document.resband1.src = imageDB[code[dig1]].src;
document.resband2.src = imageDB[code[dig2]].src;
document.multband.src = imageDB[code[mult]].src;
document.tolband.src = imageDB[tolerance[tol]].src;}
}
}
var table = "
" +
"
" +
"
" +
"
" +
"
" +
"
"+
"
"
function calculatemult3 (multiplier,value)
//calculates multipliers Milli - Pico
{if (multiplier==0)
{return value;}
else if (multiplier==1)
{return value /= 1000;}
else if (multiplier==2)
{return value /= 1000000;}
else if (multiplier==3)
{return value /= 1000000000;}
else if (multiplier==4)
{return value /= 1000000000000;}
}
</script>