I think you want to show that in each ideal class the number of ideals of norm a is equal to the number of ideals of norm $a \cdot |D|$. This should follow directly from the following 2 facts.

(1).  All primes $p$ dividing $|D|$ ramify in the ring of integers of $\mathbb{Q}(\sqrt{D})$.

(2).  The unique ideal of norm $|D|$ (uniqueness and existence follow from (1), taking a little care about the prime $2$) is principal, generated by $\sqrt{D}$.

In view of (1) and (2) the map $J \rightarrow \sqrt{D} \cdot J$ gives the desired bijection.