You need to push your shape on ArcGIS Online, there is a cheap developper access account fee to do it.
Then, here is the link in javascript to render polygons in several colors based on an attribute (ID, or whatever), using a Renderer Using a UniqueValueRenderer
for getting the polygons on which apply the colors by a spatial query, you can use this technique : Using a Query from FeatureLayer