First order explanation:
DJIA weighs against the stock price for the 30 companies it tracks. For example Stock A is $40/share while Stock B is $20/share Stock A's movements will affect ~ 67% of the two stock "DJIA" index.
S&P 500 weighs against the market cap of companies. Therefore one ultra-cap company will have a dominate affect on the index movement verses many less large cap companies.
I only talked about two major indices but the formula for calculating their "price" is pretty involved.
Check out some books on stocks and indexes or visit websites like investopedia.com, fool.com, etc. Also the indices and stock exchanges have their own websites which will go into more detail.