Skip to Content
0
Former Member
Nov 13, 2006 at 05:35 PM

Problem with comparison in Javascript - re-posted for clarity

35 Views

Hi sdn,

Below is a simple function returning an icon depending upon the cell value. But the switch statement never works. I pass the cell_value to the function as follows:

==========================================================

for (var rowno =1;rowno < obj.rows.length-1;rowno++) { obj.rows(rowno).cells(3).width = 50; obj.rows(rowno).cells(3).innerHTML = getIcon(obj.rows(rowno).cells(3).innerHTML); }

==========================================================

The troubling function is as follows:

==========================================================

function getIcon(Cell_Value){ var icon switch (Cell_Value){ case -2.000: icon= "" break; case -1.000: icon= "" break; case 0.000: icon= "" break; case 1.000: icon= "" break; case 2.000: icon= "" break; } return icon }

Can someone please tell me how do I make this comparison to replace value with an icon. I alway award points.

Thx.

Saf.