Place the cup of water with the onion roots in full sun. A sunny windowsill (preferably a south-facing window) is the best way to regrow these young plants.
Once the green parts of the onion grow long, you can harvest by cutting as much of the green off as you need for your recipe, keeping the remainder of the plant in the water.