Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. function estweight(form){
  4.  
  5.   var bfactor = 0;
  6.  
  7.   var i = buttonchoice(form.fishclass);
  8.  
  9.   var b = buttonselect(form.fishbody);
  10.  
  11.   var decimals = 2;
  12.  
  13.   if (form.girth.value < 1){
  14.  
  15.     var girth_number = 0.58 * form.length.value;
  16.  
  17.     var girth1 = girth_number * Math.pow(10, decimals);
  18.  
  19.     var girth2 = perRound(girth1);
  20.  
  21.     form.girth.value = perRound(girth2 / Math.pow(10, decimals));
  22.  
  23.     form.MG.value = perRound((girth2 * 25.4)/ Math.pow(10, decimals));
  24.  
  25.     form.CG.value = perRound((girth2 * 2.54)/ Math.pow(10, decimals));
  26.  
  27.   }
  28.  
  29.  
  30.  
  31.   if (b == 0){bfactor = 1;}
  32.  
  33.   if (b == 1){bfactor = 1.05;}
  34.  
  35.   if (b == 2){bfactor = .95;}
  36.  
  37.  
  38.  
  39.   if (i == 0){var weight_number = eval(form.length.value * form.girth.value * form.girth.value / 900);} // OK
  40.  
  41.   if (i == 1){var weight_number = eval(form.length.value * form.girth.value * form.girth.value / 800);}
  42.  
  43.   if (i == 2){var weight_number = eval(form.length.value * form.length.value * form.girth.value / 1200);} // OK
  44.  
  45.   if (i == 3){var weight_number = eval(form.length.value * form.length.value * form.length.value / 1200); form.girth.value=0; form.MG.value=0; form.CG.value=0;}
  46.  
  47.   if (i == 4){var weight_number = eval(form.length.value * form.length.value * form.length.value / 3500); form.girth.value=0; form.MG.value=0; form.CG.value=0;} // OK
  48.  
  49.   if (i == 5){var weight_number = eval(form.length.value * form.length.value * form.length.value / 1600); form.girth.value=0; form.MG.value=0; form.CG.value=0;} // OK
  50.  
  51.   if (i == 6){var weight_number = eval(form.length.value * form.length.value * form.length.value / 2500); form.girth.value=0; form.MG.value=0; form.CG.value=0;}
  52.  
  53.   if (i == 7){var weight_number = eval(form.length.value * form.length.value * form.length.value / 5500); form.girth.value=0; form.MG.value=0; form.CG.value=0;} // OK
  54.  
  55.   if (i == 8){var weight_number = eval(form.length.value * form.length.value * form.length.value / 2800); form.girth.value=0; form.MG.value=0; form.CG.value=0;} // OK
  56.  
  57.   var weight1 = weight_number * Math.pow(10, decimals);
  58.  
  59.   var weight2 = perRound(weight1);
  60.  
  61.   form.weight.value = perRound(weight2 / Math.pow(10, decimals));
  62.  
  63.   form.G.value = perRound((weight2 * 453.592) / Math.pow(10, decimals));
  64.  
  65.   form.K.value = perRound((weight2 * .453592) / Math.pow(10, decimals));
  66.  
  67. }
  68.  
  69. function buttonchoice(buttonclass) {
  70.  
  71.   for (var i = 0; i < buttonclass.length; i++) {
  72.  
  73.     if (buttonclass[i].checked) {
  74.  
  75.       return i
  76.  
  77.     }
  78.  
  79.   }
  80.  
  81. }
  82.  
  83.  
  84.  
  85. function buttonselect(buttonselect) {
  86.  
  87.   for (var b = 0; b < buttonselect.length; b++) {
  88.  
  89.     if (buttonselect[b].checked) {
  90.  
  91.       return b
  92.  
  93.     }
  94.  
  95.   }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement