What's wrong with this code?

This script isn’t working like it should and I’m not sure why. I’m new to Javascript programming so the obvious won’t be so obvious to me. When I run the script thru the IE debugger, the variable “mnuItm” does contain one ofthe values in the case clause but it’s not taking that path. It takes the “Default” path when it shouldn’t.

I also tried using the “id” as the switch object and that worked. I have no idea why one works and the other doesn’t. Please help!

Thanks,

Blake


	function NoFunctionality(id)
	{
  		var blnRedirect = true;
			
		mnuItm = document.getElementById(id).innerText;	*/
				
		switch ( mnuItm ) 
		{
			case 'liPhase1':
				alert("Phase 1 functionality is not yet implemented!");						
				blnRedirect = false;
				break;
			case 'liPhase2':
				alert("Phase 2 functionality is not yet implemented!");
				blnRedirect = false;
				break;
			case 'liPhase3':
				alert("Phase 3 functionality is not yet implemented!");
				blnRedirect = false;
				break;
			case 'liPhase4':
				alert("'Phase 4 functionality is not yet implemented!");
				blnRedirect = false;
				break;
			default:
				alert("Unknown Selection!");
				break;
		}
	}
				
			

Well, first take out */.

Everything else looks okay though. You just need to make sure that the id value you are passing in is valid.

Also, try adding “alert(mnuItm)” before the switch and visually see if the value you are getting is one of your options.

Removing the */ didn’t help. However, when I did the alert on the mnuItm, it still showed the correct value which should have been reflected in the Switch statement.

Select the text in the alert and see if it has any random spaces or anything in there.

Be aware that innerText is not globally supported and should not be used on the web.