Well, you've already started, so this is too late but I just did practically the same trip.
You're going to a National Park area in peak season so rooms are tough to come by and can be very expensive. I would recommend sticking to a tighter schedule and reserving rooms in advance. I normally just roll but the combination of NP's and high season means a poor planner might sleep by the side of the road. I don't camp.
Jackson is high priced but super cool in a touristy way, anything near Yellowstone is high but there are some bargains to be found. Avoid the Rodeway Inn in Livingston MT, $160 a night for what you get is ridiculous, just robbery. Much closer to Yellowstone is Gardiner MT, just outside the north entrance. We stayed at the Yellowstone River Inn (in the 'new building') and I can't recommend it enough. Nice lady that runs the place and the maid is a smokin hot Czech girl named Magda who is lovely and just as nice as a human being can be. Ridiculous view out the back over the river.
We stayed in Kalispell the night before we did Glacier at the Econolodge, which is was reasonable and nice. Right on the main drag, tons of places to eat, gas up, buy stuff etc. There are places that are closer up the road in Columbia Falls and West Glacier, they may be more, I know nothing of them. The Econolodge was perfect.
We also spent a lot of time in Idaho, which I can't recommend highly enough, the path we took anyway. We went from Gardiner MT to Stanley ID in one day. Fantastic roads, Stanley is lovely. Next night was Kamiah, great roads to there also and we ate downtown in the old bank, stayed at the Clearwater. Next day was Lolo Pass (fantastic!!) to Kalispell. Of course, Glacier is stunning.