Jump to content

JS Nested if else Statement Help

I am attempting to write a nested if statement in JavaScript and it is not working. I am not sure what I am doing wrong and would like some assistance. The if statements are long and will only get longer. I choose to use if statements simply because I do not know how to create a VLOOKUP type function in JS. I have researched a way to accomplish this and found various codes, the problem is I do not understand them thus I cannot edit them to fit my needs. Any help will be greatly appreciated!

 

	/* The following vars are used to get the proposed kWh */
	var apropkWh1;
	var apropkWh2;
	var apropkWh3;
	var apropkWh4;
	var apropkWh5;
	/* The following vars are used to get the proposed kWh */
	var propkWh1 = if (document.getElementById("RbR5.1").value = document.getElementById("RN1.1").value) {apropkWh1 = document.getElementById("RN5.1").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.2").value) {apropkWh1 = document.getElementById("RN5.2").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.3").value) {apropkWh1 = document.getElementById("RN5.3").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.4").value) {apropkWh1 = document.getElementById("RN5.4").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.5").value) {apropkWh1 = document.getElementById("RN5.5").value * document.getElementById("burnHrs1").value;}
	var propkWh2 = if (document.getElementById("RbR5.2").value = document.getElementById("RN1.1").value) {apropkWh2 = document.getElementById("RN5.1").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.2").value) {apropkWh2 = document.getElementById("RN5.2").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.3").value) {apropkWh2 = document.getElementById("RN5.3").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.4").value) {apropkWh2 = document.getElementById("RN5.4").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.5").value) {apropkWh2 = document.getElementById("RN5.5").value * document.getElementById("burnHrs2").value;}
	var propkWh3 = if (document.getElementById("RbR5.3").value = document.getElementById("RN1.1").value) {apropkWh3 = document.getElementById("RN5.1").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.2").value) {apropkWh3 = document.getElementById("RN5.2").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.3").value) {apropkWh3 = document.getElementById("RN5.3").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.4").value) {apropkWh3 = document.getElementById("RN5.4").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.5").value) {apropkWh3 = document.getElementById("RN5.5").value * document.getElementById("burnHrs3").value;}
	var propkWh4 = if (document.getElementById("RbR5.4").value = document.getElementById("RN1.1").value) {apropkWh4 = document.getElementById("RN5.1").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.2").value) {apropkWh4 = document.getElementById("RN5.2").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.3").value) {apropkWh4 = document.getElementById("RN5.3").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.4").value) {apropkWh4 = document.getElementById("RN5.4").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.5").value) {apropkWh4 = document.getElementById("RN5.5").value * document.getElementById("burnHrs4").value;}
	var propkWh5 = if (document.getElementById("RbR5.5").value = document.getElementById("RN1.1").value) {apropkWh5 = document.getElementById("RN5.1").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.2").value) {apropkWh5 = document.getElementById("RN5.2").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.3").value) {apropkWh5 = document.getElementById("RN5.3").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.4").value) {apropkWh5 = document.getElementById("RN5.4").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.5").value) {apropkWh5 = document.getElementById("RN5.5").value * document.getElementById("burnHrs5").value;}

 

Legends never die.

Link to comment
Share on other sites

Link to post
Share on other sites

if is not a a function, so it doesn't return value, to save boolean result just do

 

var b = (true == false || 1 > 0);

also, = is asignment operator, == is compare operator. So you're not comparing, but assigning.

 

Anyway, use loop and array instead writing all this by hand.

 

Edit: I just read one line of your contraption.

if(document.getElementById("RbR5.1").value == document.getElementById("RN1.1").value){
	apropkWh1 = document.getElementById("RN5.1").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value == document.getElementById("RN1.2").value) {
	apropkWh1 = document.getElementById("RN5.2").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.3").value) {
  	apropkWh1 = document.getElementById("RN5.3").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.4").value) {
  	apropkWh1 = document.getElementById("RN5.4").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.5").value) {
  	apropkWh1 = document.getElementById("RN5.5").value * document.getElementById("burnHrs1").value;
}

And I actually have no idea what would you expect to propkWh1 contain after.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, Mr_KoKa said:

if is not a a function, so it doesn't return value, to save boolean result just do

 


var b = (true == false || 1 > 0);

also, = is asignment operator, == is compare operator. So you're not comparing, but assigning.

 

Anyway, use loop and array instead writing all this by hand.

Well that makes sense. How exactly would I write that loop? Would the values in the array equal the values in the table (see example below)?

 

var b = [document.getElementById("value1").value, document.getElementById("value2").value, document.getElementById("value3").value];

 

Legends never die.

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, Mr_KoKa said:

var b = (true == false || 1 > 0);

Anyway, use loop and array instead writing all this by hand.

 

Edit: I just read one line of your contraption.


if(document.getElementById("RbR5.1").value == document.getElementById("RN1.1").value){
	apropkWh1 = document.getElementById("RN5.1").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value == document.getElementById("RN1.2").value) {
	apropkWh1 = document.getElementById("RN5.2").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.3").value) {
  	apropkWh1 = document.getElementById("RN5.3").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.4").value) {
  	apropkWh1 = document.getElementById("RN5.4").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.5").value) {
  	apropkWh1 = document.getElementById("RN5.5").value * document.getElementById("burnHrs1").value;
}

And I actually have no idea what would you expect to propkWh1 contain after.

 

 

Contraption is a very accurate term. The idea is, based on what unit code the user selects, the JS  code will find that code, enter the wattage, and then multiply that wattage by the burn hours to get the kilowatt-hours (kWh). Does that make sense?

Legends never die.

Link to comment
Share on other sites

Link to post
Share on other sites

if your table has assigned id's to its cells then yes. But still don't know what you have expected to propkWh1 contain.

 

Let me just rewrite two of your if's to see what changes.

if(document.getElementById("RbR5.1").value == document.getElementById("RN1.1").value){
	apropkWh1 = document.getElementById("RN5.1").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value == document.getElementById("RN1.2").value) {
	apropkWh1 = document.getElementById("RN5.2").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.3").value) {
  	apropkWh1 = document.getElementById("RN5.3").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.4").value) {
  	apropkWh1 = document.getElementById("RN5.4").value * document.getElementById("burnHrs1").value;
} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.5").value) {
  	apropkWh1 = document.getElementById("RN5.5").value * document.getElementById("burnHrs1").value;
}
if (document.getElementById("RbR5.2").value = document.getElementById("RN1.1").value) {
	apropkWh2 = document.getElementById("RN5.1").value * document.getElementById("burnHrs2").value;
} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.2").value) {
  	apropkWh2 = document.getElementById("RN5.2").value * document.getElementById("burnHrs2").value;
} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.3").value) {
  	apropkWh2 = document.getElementById("RN5.3").value * document.getElementById("burnHrs2").value;
} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.4").value) {
  	apropkWh2 = document.getElementById("RN5.4").value * document.getElementById("burnHrs2").value;
} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.5").value) {
  	apropkWh2 = document.getElementById("RN5.5").value * document.getElementById("burnHrs2").value;
}

so in first you compare RBR5.1 and multiply by burnHrs1, in the second one RbR5.2 and burnHrs2

 

apropkWh = [0, 0, 0, 0, 0];
for(var i = 1; i <= 5; i++){
  var RbR = document.getElementById("RbR5." + i).value;

  for(var k = 1; k <= 5; k++){      	
    if(RbR == document.getElementById("RN1." + k).value){
      apropkWh[i - 1] = document.getElementById("RN5." + k).value * document.getElementById("butnHrs" + i);
      break; //If one of ifs is true then there is no need to check others.
    }
  }
}

But I might made mistake as there is a loot of similar looking variables names.

apropkWh array is indexed from 0, so this is why there is i - 1, but you can make 6 element array and do i instead, leaving 0-index element unchanged.

(I struggled with edit, because it was turning my [ i ] to bbcode)

Link to comment
Share on other sites

Link to post
Share on other sites

Can you screenshot how it looks in the browsers, or at least what units are available?

Can you make one example of such convertion?

 

I would create such table as array so you don't need to iterate through your html DOM to find what unit is chosen and what multiplier to apply.

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, Mr_KoKa said:

Can you screenshot how it looks in the browsers, or at least what units are available?

Can you make one example of such convertion?

 

I would create such table as array so you don't need to iterate through your html DOM to find what unit is chosen and what multiplier to apply.

I just ran your loop edit and it returned NaN, I consider that a step in the right direction as my code didn't even run (obviously). I am going to try to edit your code to see if I can get it work return what I need. I have attached a screenshot of the table and the HTML and JS files. There is a lot there.

 

Spoiler

ScreenShot.jpg

 

Spoiler

I am having trouble uploading the HTML file, so I just copied the code.

 

</br>
	<div class="TableDIV">
		<table width="100%">
			<tr>
				<th class="Instructions" colspan="8">Retro New</th>
			</tr>
			<tr>
				<th class="Secondary">Ref. Nr.</th>
				<th class="Secondary">Unit Code</th>
				<th class="Secondary">Category</th>
				<th class="Secondary">Retrofit or Replacment</th>
				<th class="Secondary">Unit Description</th>
				<th class="Secondary">System Watts</th>
				<th class="Secondary">Cost</th>
				<th class="Secondary">Labor in Minutes</th>
			</tr>
			<tr>
				<td class="RetroNew">0</td>
				<td class="RetroNew">1</td>
				<td class="RetroNew">2</td>
				<td class="RetroNew">3</td>
				<td class="RetroNew">4</td>
				<td class="RetroNew">5</td>
				<td class="RetroNew">6</td>
				<td class="RetroNew">7</td>
			</tr>
			<tr>
				<td class="RetroNew">1</td>
				<td class="RetroNew2" id="RN1.1">140LED</td>
				<td class="RetroNew2" id="RN2.1">Lamps</td>
				<td class="RetroNew2" id="RN3.1">Retrofit</td>
				<td id="RN4.1">Retrofit with one equivalent wattage LED screw-in lamp. Replace a 40W incandescent lamp.</td>
				<td class="RetroNew2" id="RN5.1"></td>
				<td class="RetroNew2" id="RN6.1"></td>
				<td class="RetroNew2" id="RN7.1"></td>
			</tr>
			<tr>
				<td class="RetroNew">2</td>
				<td class="RetroNew2" id="RN1.2">160LED</td>
				<td class="RetroNew2" id="RN2.2">Lamps</td>
				<td class="RetroNew2" id="RN3.2">Retrofit</td>
				<td id="RN4.2">Retrofit with one equivalent wattage LED screw-in lamp. Replace a 60W incandescent lamp.</td>
				<td class="RetroNew2" id="RN5.2"></td>
				<td class="RetroNew2" id="RN6.2"></td>
				<td class="RetroNew2" id="RN7.2"></td>
			</tr>
			<tr>
				<td class="RetroNew">3</td>
				<td class="RetroNew2" id="RN1.3">175LED</td>
				<td class="RetroNew2" id="RN2.3">Lamps</td>
				<td class="RetroNew2" id="RN3.3">Retrofit</td>
				<td id="RN4.3">Retrofit with one equivalent wattage LED screw-in lamp. Replace a 75W incandescent lamp.</td>
				<td class="RetroNew2" id="RN5.3"></td>
				<td class="RetroNew2" id="RN6.3"></td>
				<td class="RetroNew2" id="RN7.3"></td>
			</tr>
			<tr>
				<td class="RetroNew">4</td>
				<td class="RetroNew2" id="RN1.4">132LED</td>
				<td class="RetroNew2" id="RN2.4">Lamps</td>
				<td class="RetroNew2" id="RN3.4">Retrofit</td>
				<td id="RN4.4">Retrofit with one LED T8 4ft lamp. The LED should be a direct wire lamp with a CCT of 4,000 degrees Kelvin, a CRI of 80 or higher, a L70 life span of 50,000 hours or longer, a light output of 1,600 lumens or higher, and a 5yr manufacturers warranty. Replaces a F32T8 lamp.</td>
				<td class="RetroNew2" id="RN5.4"></td>
				<td class="RetroNew2" id="RN6.4"></td>
				<td class="RetroNew2" id="RN7.4"></td>
			</tr>
			<tr>
				<td class="RetroNew">5</td>
				<td class="RetroNew2" id="RN1.5">232LED</td>
				<td class="RetroNew2" id="RN2.5">Lamps</td>
				<td class="RetroNew2" id="RN3.5">Retrofit</td>
				<td id="RN4.5">Retrofit with two LED T8 4ft lamp. The LED should be a direct wire lamp with a CCT of 4,000 degrees Kelvin, a CRI of 80 or higher, a L70 life span of 50,000 hours or longer, a light output of 1,600 lumens or higher, and a 5yr manufacturers warranty. Replaces two F32T8 lamps.</td>
				<td class="RetroNew2" id="RN5.5"></td>
				<td class="RetroNew2" id="RN6.5"></td>
				<td class="RetroNew2" id="RN7.5"></td>
			</tr>
			<tr>
				<td class="RetroNew">6</td>
				<td class="RetroNew2" id="RN1.6">332LED</td>
				<td class="RetroNew2" id="RN2.6">Lamps</td>
				<td class="RetroNew2" id="RN3.6">Retrofit</td>
				<td id="RN4.6">Retrofit with three LED T8 4ft lamp. The LED should be a direct wire lamp with a CCT of 4,000 degrees Kelvin, a CRI of 80 or higher, a L70 life span of 50,000 hours or longer, a light output of 1,600 lumens or higher, and a 5yr manufacturers warranty. Replaces three F32T8 lamps.</td>
				<td class="RetroNew2" id="RN5.6"></td>
				<td class="RetroNew2" id="RN6.6"></td>
				<td class="RetroNew2" id="RN7.6"></td>
			</tr>
			<tr>
				<td class="RetroNew">7</td>
				<td class="RetroNew2" id="RN1.7">NWPLED150</td>
				<td class="RetroNew2" id="RN2.7">Wallpacks</td>
				<td class="RetroNew2"  id="RN3.7">Replacement</td>
				<td id="RN4.7">Replace the existing wall pack with a new purpose built, equivalent wattage LED wall pack. Replacement fixture should have at a minimum an initial light output of 4,000 lumens, a 5 year warranty, a CCT of 4,000 degrees Kelvin or higher, a CRI of 70 or greater, a life to L70 of 100,000 hours or longer, and an efficacy of 75 lumens per watt or better. Replaces 150W HID.</td>
				<td class="RetroNew2" id="RN5.7"></td>
				<td class="RetroNew2" id="RN6.7"></td>
				<td class="RetroNew2" id="RN7.7"></td>
			</tr>
			<tr>
				<td class="RetroNew">8</td>
				<td class="RetroNew2" id="RN1.8">NWPLED100</td>
				<td class="RetroNew2" id="RN2.8">Wallpacks</td>
				<td class="RetroNew2" id="RN3.8">Replacement</td>
				<td id="RN4.8">Replace the existing wall pack with a new purpose built, equivalent wattage LED wall pack. Replacement fixture should have at a minimum an initial light output of 1,600 lumens, a 5 year warranty, a CCT of 4,000 degrees Kelvin or higher, a CRI of 65 or greater, a life to L70 of 100,000 hours or longer, and an efficacy of 60 lumens per watt or better. Replaces 100W HID.</td>
				<td class="RetroNew2" id="RN5.8"></td>
				<td class="RetroNew2" id="RN6.8"></td>
				<td class="RetroNew2" id="RN7.8"></td>
			</tr>
			<tr>
				<td class="RetroNew">9</td>
				<td class="RetroNew2" id="RN1.9">N2x4TLED232</td>
				<td class="RetroNew2" id="RN2.9">Recessed Troffers</td>
				<td class="RetroNew2" id="RN3.9">Replacement</td>
				<td id="RN4.9">Replace the existing troffer with a new purpose built LED 2x4 troffer. Replacement troffer should have at a minimum a 5 year warranty, a CCT of 4,000 degrees Kelvin or higher, a CRI of 80 or greater, a life to L70 of 50,000 hours or longer, and an efficacy of 90 lumens per watt or better. Replaces 2-lamp troffer.</td>
				<td class="RetroNew2" id="RN5.9"></td>
				<td class="RetroNew2" id="RN6.9"></td>
				<td class="RetroNew2" id="RN7.9"></td>
			</tr>
			<tr>
				<td class="RetroNew">10</td>
				<td class="RetroNew2" id="RN1.10">N2x4TLED332</td>
				<td class="RetroNew2" id="RN2.10">Recessed Troffers</td>
				<td class="RetroNew2" id="RN3.10">Replacement</td>
				<td id="RN4.10">Replace the existing troffer with a new purpose built LED 2x4 troffer. Replacement troffer should have at a minimum a 5 year warranty, a CCT OF 4,000 degrees Kelvin or higher, a CRI of 80 or greater, a life to L70 of 50,000 hours or longer, and an efficacy of 90 lumens per watt or better. Replaces 3-lamp troffer.</td>
				<td class="RetroNew2" id="RN5.10"></td>
				<td class="RetroNew2" id="RN6.10"></td>
				<td class="RetroNew2" id="RN7.10"></td>
			</tr>
		</table>
	</div>
</br>
</br>
	<div class="TableDIV">
		<table width="100%">
			<tr>
				<th class="Instructions" colspan="100%">RbR by ECM/O</th>
			</tr>
			<tr>
				<th class="Secondary">Ref. Nr.</th>
				<th class="Secondary">Existing Unit</th>
				<th class="Secondary">Existing Control</th>
				<th class="Secondary">Qty</th>
				<th class="Secondary">Proposed Unit</th>
				<th class="Secondary">Proposed Control</th>
				<th class="Secondary">Proposed Control Qty</th>
				<th class="Secondary">Existing kWh</th>
				<th class="Secondary">Proposed kWh</th>
				<th class="Secondary">kWh Savings</th>
				<th class="Secondary">kWh Dollar Savings</th>
				<th class="Secondary">Existing Burn Hours</th>
				<th class="Secondary">Proposed Burn Hours</th>
				<th class="Secondary">Burn Hour Savings</th>
				<th class="Secondary">Control kWh Savings</th>
				<th class="Secondary">Control kWh Dollar Savings</th>
				<th class="Secondary">Total kWh Dollar Savings</th>
				<th class="Secondary">O&M Dollar Savings</th>
				<th class="Secondary">Total Savings</th>
				<th class="Secondary">Total Cost</th>
				<th class="Secondary">SPB</th>
			</tr>
			<tr>
				<td class="RBR">0</td>
				<td class="RBR">1</td>
				<td class="RBR">2</td>
				<td class="RBR">3</td>
				<td class="RBR">4</td>
				<td class="RBR">5</td>
				<td class="RBR">6</td>
				<td class="RBR">7</td>
				<td class="RBR">8</td>
				<td class="RBR">9</td>
				<td class="RBR">10</td>
				<td class="RBR">11</td>
				<td class="RBR">12</td>
				<td class="RBR">13</td>
				<td class="RBR">14</td>
				<td class="RBR">15</td>
				<td class="RBR">16</td>
				<td class="RBR">17</td>
				<td class="RBR">18</td>
				<td class="RBR">19</td>
				<td class="RBR">20</td>
			</tr>
			<tr>
				<td class="RBR">1</td>
				<td class="RbR2" id="RbR1.1"></td>
				<td class="RbR2" id="RbR2.1"></td>
				<td class="RbR2" id="RbR3.1"></td>
				<td class="RbR2" id="RbR4.1"></td>
				<td class="RbR2" id="RbR5.1"></td>
				<td class="RbR2" id="RbR6.1"></td>
				<td class="RbR2" id="RbR7.1"></td>
				<td class="RbR2" id="RbR8.1"></td>
				<td class="RbR2" id="RbR9.1"></td>
				<td class="RbR2" id="RbR10.1"></td>
				<td class="RbR2" id="RbR11.1"></td>
				<td class="RbR2" id="RbR12.1"></td>
				<td class="RbR2" id="RbR13.1"></td>
				<td class="RbR2" id="RbR14.1"></td>
				<td class="RbR2" id="RbR15.1"></td>
				<td class="RbR2" id="RbR16.1"></td>
				<td class="RbR2" id="RbR17.1"></td>
				<td class="RbR2" id="RbR18.1"></td>
				<td class="RbR2" id="RbR19.1"></td>
				<td class="RbR2" id="RbR20.1"></td>
			</tr>
			<tr>
				<td class="RBR">2</td>
				<td class="RbR2" id="RbR1.2"></td>
				<td class="RbR2" id="RbR2.2"></td>
				<td class="RbR2" id="RbR3.2"></td>
				<td class="RbR2" id="RbR4.2"></td>
				<td class="RbR2" id="RbR5.2"></td>
				<td class="RbR2" id="RbR6.2"></td>
				<td class="RbR2" id="RbR7.2"></td>
				<td class="RbR2" id="RbR8.2"></td>
				<td class="RbR2" id="RbR9.2"></td>
				<td class="RbR2" id="RbR10.2"></td>
				<td class="RbR2" id="RbR11.2"></td>
				<td class="RbR2" id="RbR12.2"></td>
				<td class="RbR2" id="RbR13.2"></td>
				<td class="RbR2" id="RbR14.2"></td>
				<td class="RbR2" id="RbR15.2"></td>
				<td class="RbR2" id="RbR16.2"></td>
				<td class="RbR2" id="RbR17.2"></td>
				<td class="RbR2" id="RbR18.2"></td>
				<td class="RbR2" id="RbR19.2"></td>
				<td class="RbR2" id="RbR20.2"></td>
			</tr>
			<tr>
				<td class="RBR">3</td>
				<td class="RbR2" id="RbR1.3"></td>
				<td class="RbR2" id="RbR2.3"></td>
				<td class="RbR2" id="RbR3.3"></td>
				<td class="RbR2" id="RbR4.3"></td>
				<td class="RbR2" id="RbR5.3"></td>
				<td class="RbR2" id="RbR6.3"></td>
				<td class="RbR2" id="RbR7.3"></td>
				<td class="RbR2" id="RbR8.3"></td>
				<td class="RbR2" id="RbR9.3"></td>
				<td class="RbR2" id="RbR10.3"></td>
				<td class="RbR2" id="RbR11.3"></td>
				<td class="RbR2" id="RbR12.3"></td>
				<td class="RbR2" id="RbR13.3"></td>
				<td class="RbR2" id="RbR14.3"></td>
				<td class="RbR2" id="RbR15.3"></td>
				<td class="RbR2" id="RbR16.3"></td>
				<td class="RbR2" id="RbR17.3"></td>
				<td class="RbR2" id="RbR18.3"></td>
				<td class="RbR2" id="RbR19.3"></td>
				<td class="RbR2" id="RbR20.3"></td>
			</tr>
			<tr>
				<td class="RBR">4</td>
				<td class="RbR2" id="RbR1.4"></td>
				<td class="RbR2" id="RbR2.4"></td>
				<td class="RbR2" id="RbR3.4"></td>
				<td class="RbR2" id="RbR4.4"></td>
				<td class="RbR2" id="RbR5.4"></td>
				<td class="RbR2" id="RbR6.4"></td>
				<td class="RbR2" id="RbR7.4"></td>
				<td class="RbR2" id="RbR8.4"></td>
				<td class="RbR2" id="RbR9.4"></td>
				<td class="RbR2" id="RbR10.4"></td>
				<td class="RbR2" id="RbR11.4"></td>
				<td class="RbR2" id="RbR12.4"></td>
				<td class="RbR2" id="RbR13.4"></td>
				<td class="RbR2" id="RbR14.4"></td>
				<td class="RbR2" id="RbR15.4"></td>
				<td class="RbR2" id="RbR16.4"></td>
				<td class="RbR2" id="RbR17.4"></td>
				<td class="RbR2" id="RbR18.4"></td>
				<td class="RbR2" id="RbR19.4"></td>
				<td class="RbR2" id="RbR20.4"></td>
			</tr>
			<tr>
				<td class="RBR">5</td>
				<td class="RbR2" id="RbR1.5"></td>
				<td class="RbR2" id="RbR2.5"></td>
				<td class="RbR2" id="RbR3.5"></td>
				<td class="RbR2" id="RbR4.5"></td>
				<td class="RbR2" id="RbR5.5"></td>
				<td class="RbR2" id="RbR6.5"></td>
				<td class="RbR2" id="RbR7.5"></td>
				<td class="RbR2" id="RbR8.5"></td>
				<td class="RbR2" id="RbR9.5"></td>
				<td class="RbR2" id="RbR10.5"></td>
				<td class="RbR2" id="RbR11.5"></td>
				<td class="RbR2" id="RbR12.5"></td>
				<td class="RbR2" id="RbR13.5"></td>
				<td class="RbR2" id="RbR14.5"></td>
				<td class="RbR2" id="RbR15.5"></td>
				<td class="RbR2" id="RbR16.5"></td>
				<td class="RbR2" id="RbR17.5"></td>
				<td class="RbR2" id="RbR18.5"></td>
				<td class="RbR2" id="RbR19.5"></td>
				<td class="RbR2" id="RbR20.5"></td>
			</tr>
		</table>
	</div>
</br>

 

Legends never die.

Link to comment
Share on other sites

Link to post
Share on other sites

The code reminds me of how de-compiled code looks like, all obfuscated and with random variable names based on their type-name and increment number.

 

I can't help it much but you have to know that .value member is only owned by inputs, all other html elements has to be read by innerHtml or better innerText.

but all values of innerText are strings that has to probably converted by parseInt / parseFloat functions, sometimes it occurres automatically when used with operator where one side is already other type (int, float).

 

Instead doing all at once, try some snippets to see how to read cell, cosole.log it out, to see what value it returns, strings will appear as "14.9" float will appear just as 14.9 (probably font color will be also different). If you haven't used console.log before, it dumps contents of variable to console that you can open by F12 (at least firefox, chrome).

 

Then step it up by populating whole row, and finally whole table.

 

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Mr_KoKa said:

The code reminds me of how de-compiled code looks like, all obfuscated and with random variable names based on their type-name and increment number.

 

I can't help it much but you have to know that .value member is only owned by inputs, all other html elements has to be read by innerHtml or better innerText.

but all values of innerText are strings that has to probably converted by parseInt / parseFloat functions, sometimes it occurres automatically when used with operator where one side is already other type (int, float).

 

Instead doing all at once, try some snippets to see how to read cell, cosole.log it out, to see what value it returns, strings will appear as "14.9" float will appear just as 14.9 (probably font color will be also different). If you haven't used console.log before, it dumps contents of variable to console that you can open by F12 (at least firefox, chrome).

 

Then step it up by populating whole row, and finally whole table.

 

Thank you for your help so far! I have only known about CSS, JS, and HTML for roughly two weeks now so to say that I am a beginner is a bit of an understatement. I will use the tips you gave me here and see if I can figure this out. I will post an update here just to let you know if I accomplished my goal.

 

Thanks again!

Legends never die.

Link to comment
Share on other sites

Link to post
Share on other sites

41 minutes ago, Mr_KoKa said:

Can you screenshot how it looks in the browsers, or at least what units are available?

Can you make one example of such convertion?

 

I would create such table as array so you don't need to iterate through your html DOM to find what unit is chosen and what multiplier to apply.

totally agree, pull all the data you and store them in an array and dictionary

Quote

myvar = [

{'name':'ben','age':'23'},

{'name':'amy','age':'22'}

]

myvar[0].name is ben

myvar[1].age is 22

then you can just loop through myvar calculating as you go or of you only need one value per iron just use a list.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×