Rules on pp 124 for Elephants state that any unit contacted by an Elephant stand that is moving as a result of a blunder, a drive back from shooting or a retreat from combat is rampaged through by the elephant, including units they are alrady touching when they start to move.
Units rampaged through must test for confusuion on a 6, or if already confused will be destroyed if a 6 is rolled.
Example #1 Sh=shooter, El = Elephant, Inf=Infantry
Sh Sh Sh
El El El
InfInfInf
The shooters inflict hits on the elephants and roll far enough for drive back to drive the Elephants into the Infantry behind and out the other side. The Infantry count as having been "rampaged through" at the point the Elephants touch them during the drive back move, so the Infantry must roll for confusion when the Elephants touch them.
Sh Sh Sh
El El El
InfInfInf
If the Infantry are friendly, they can choose to make way, rolling again for confusion. Then the Elephants roll for confusion.
If the infantry are not friendly or refuse to make way, the Elephants will halt as per the confusion rules, and the Elephants become confused.