I’m sorry for the bad title (edit if you wish), but I don’t know how to put this request. I attached an image from Photoshop that illustrates things a little bit better.
The request itself is quite simple: You have a numeric range from 10.0 to 0.0.
10 stands for the color #00ff00 (deep green) and 0.0 for the color #ff0000 (deep red).
Now, when you hand over the number 10.0 it will output #00ff00. When you give it something like 8.2 it would output something like #00cc33 so that you have a floating gradient all the way down but always float from #00ff00 over orange #ff9900 to #ff0000 (orange in the middle could also be omitted).

Just for fun:
See it here (for what its worth): http://jsfiddle.net/xD6Uf/
Update
Inspired by Samuel Edwin Ward’s use of HSL, the following function adapts
hslToRgbfrom Brian Grinstead’s MIT Licensed tinycolor.js:Note: this function is not intended to be the finished article or represent good practice, it is a proof of concept only. There is no bounds checking and few concessions to readability.
nis a value from 0 to 10, andstart,middleandendare each a hue value from 0 – 360.See Mother-effing hsl to select hue, saturation and lightness values to experiment with.
Example
jsfiddle