Thank you, Ray. I am a total amateur (and don't write code for anyone except our products). I will soon need a programmer to assist with stuff like this. I checked the "community", and I don't need web development, but will soon need a "shadow programmer" to speed things like this up. This is our product page (www.iapsystems.com) .
The code you provided works great, and I will use it as a model for the future.
Too bad the charting modules have been discontinued. Hope they will be back sometime. I would sell them as a separate module, it is worth it.