Return to Snippet

Revision: 54651
at January 6, 2012 01:53 by stavelin


Initial Code
function GetOpacity(value)
	{
		var result;
		switch (true)
		{
			case (value == 0):
				result = 0;
				break;
			case ((value >= 0) && (value <= 1)): // "Between 1 and 25."
				result = 0.1;
				break;
			case ((value >= 1) && (value <= 2)): // "Between 1 and 25."
				result = 0.2;
				break;
			case ((value >= 2) && (value <= 3)): // "Between 1 and 25."
				result = 0.25;
				break;
			case ((value >= 3) && (value <= 4)): // "Between 1 and 25."
				result = 0.3;
				break;
			case ((value >= 5) && (value <= 10)): //"Between 26 and 50."
				result = 0.5;
				break;
			case ((value >= 10) && (value <= 15)): //"Between 26 and 50."
				result = 0.6;
				break;
			case ((value >= 16) && (value <= 50)): //"Between 26 and 50."
				result = 0.7;
				break;
			case ((value >= 51) && (value <= 75)): // "Between 51 and 75."
				result = 0.8;
				break;
			case ((value >= 76) && (value <= 100)): //"Between 76 and 100."
				result = 1;
				break;
			default:
				result = 0;
				break;
		}
		return result;
	}

Initial URL

                                

Initial Description
na

Initial Title
swtich with range in javascript

Initial Tags
js

Initial Language
JavaScript