cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with comparison in Javascript - re-posted for clarity

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Safdar,

I have never seen a Case statement assign icons. (But, maybe I have not looked in the right places.)

I would suggest assigning string Names to the icons. Use the Case statement to choose the one to use. Then assign the Named icon to the cell.

Hope this helps.

- Pete

P.S. Is this for WAD or Excel front end?

Former Member
0 Kudos

Hi Peter,

The problem is not with assigning icons. That part works. The problem is evaluation of Cell_Value and comparing it to number/string in the Switch statement.

These functions are in the HTML code behind WAD.

Thanks.

Saf.

Answers (0)