Clearly if n < m there can be no onto functions from A to B, because under a function each element of A can map to only one element of B.
If n = m we have a bijection. The first element of A can map to any of the m elements of B. The second element of A can map to any of the remaining m - 1 elements of B, and so on. So the total number of onto functions is m!.
If n > m, there is no simple closed formula that describes the number of onto functions. We need to count the number of partitions of A into m blocks. For example, if n = 3 and m = 2, the partitions of elements a, b, and c of A into 2 blocks are: ab,c; ac,b; bc,a. Each of these partitions then describes a function from A to B. For example, the first partition -- ab,c -- says that a and b map to one element of B, and c maps to the other. Once we've counted the partitions we multiply by m!, just as in the bijection case, because for each partition the first block can map to any of the m elements of B, and so on.
The problem is that there is no simple, non-recursive way to calculate the number of partitions of an n-set into m blocks. These numbers are known as Stirling numbers of the second kind; see the reference below. See also sections 2.1.8 and 2.1.9 of the "Twelvefold Way" link.
So the best answer we can give for the case n ≥ m is: m! S(n,m), where S(n,m) is a Stirling number of the second kind.