Faced with the prospect of farm produce rotting beside idle tracks, House and Senate gave quick approval yesterday to multimillion-dollar loans designed to get freight trains rolling again on Milwaukee Road's western lines.

The proposed legislation was whisked through both the House and Senate with little debate and sent to President Carter only hours after it emerged from a conference committee.

Senate Bob Packwood (R-Ore.) urged speed, saying, "crops are on the ground in Iowa . . . Every day we delay is one day closed to disaster."

One lawmaker said perishable farm products, such as eggs and milk, have been piling up since Thursday, when the railroad shut down service on 4,700 miles of track as an economy measure. "I don't know if they are rotting now, but they're going to rot." said Rep. Edward Madigan (R-Ill.) "They are going to rot."

Rep. James J. Florio (D-N.J.) said the closing of the western lines has created "an emergency -- shipments of coal and grain have stopped."

The bill would keep freight rolling on the western lines at least until Dec. 15. At that time, a group of employes and shippers would have to be ready with a plan to take over the railroad. Otherwise it could shut down again and start selling off the western lines.

The railroad says it wants to shed the lines in a cost-cutting move to salvage a financially viable inner core in the Midwest. Involved is 2,500 miles of its transcontinental line between Miles City, Mont., and Tacoma, Wash., plus 2,200 miles in South Dakota, Iowa, Wisconsin Illinois and Michigan.

The bill would furnish federal loans estimated at $15 million a month to keep the western lines open until Dec. 15. If service is shut down again, it would provide loans of $75 million plus grants totaling $7.2 million to cushion the blow of layoffs for Milwaukee Road workers.

If shippers and employes present a plan to take over the railroad by Dec. 15, the Interstate Commerce Commission will have until Jan. 15 to decide if it is workable.

"This action by the Congress allows time for the coalition of employes and shippers to develop a plan to assure the long-term operation of the Milwaukee through Montana and on to the Pacific Coast," Rep. Pat Williams (D-Mont.) said following passage.

But other lawmakers expressed skepticism.

"Personally, I find that the likelihood of the commission finding such a plan to be feasible is very remote," Madigan told the House.

He said such a plan would have to be drawn up "without any illusions that additional federal money will be made available in order to create an employe-shipper owned railroad."

In addition to other troubles facing the plan, attorneys for Milwaukee Road stockholders say they may challenge it in court because it specifies that the government has priority for repayment in the event of liquidation, ahead of the shareholders.