Yes, the Top 40 began with jukeboxes. In the 1940s and 1950s, store owners noticed the music that people chose to listen to most often. They would then make certain they had the more popular selections available to sell. The industry noticed this and began tracking the data, and the Top 40 could be used to inform store owners about the types of tracks to order for their machines.
Jukeboxes allowed people to play what they wanted to, when they wanted to. Before that people were mostly limited to what they could play themselves or what they could listen to on the radio. Most people could not afford record players themselves, and the jukebox gave them some control over what they could listen to.
Radio stations and advertisers started the trend when they figured out they could make a buck but the jukebox, in its prime, was the avenue those stations and advertisers used. Ultimately, live music began the trend but in order to mass produce and distribute, aside from radio, the jukebox fit the bill.
The jukebox was a highly popular form of entertainment from the 1940s through the 1960s. The American Top 40 did not begin until sometime in the 1970s. It was comprised of a list of the most popular songs played on the radio around the time that the show originally aired. Such a list would not have been possible to compile from a jukebox.