style.filter percentage to hex?
I'm working with a style.filter related function.
Some of my function appear as ...
Everything is working but I'm trying to replace the "A8" part with a percentage typed in by the viewer.
document.getElementById('audio').style.filter = 'progid:DXImageTransform.Microsoft.gradient(startColorstr=#A8' + c.substring(1) + ',endColorstr=#A8' + c.substring(1) + ')';
The percentage is simply a non-decimal number between 0 and 100 typed into a box.
I know how to grab the value of the box (again, it's 0-100) but how do I convert that number into it's "A8" equivalent?
var hex= (Math.round(parseFloat(pct)*2.55)).toString(16);
if(hex.length== 1) hex= '0'+hex;
/* returned value: (String)
var myHex= ("0000"+(Math.floor( (myNum /100) * 255 )).toString(16)).slice(-2);
Both work quite nicely. Thanks!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)