It can be challenging to complete a true CPR certification online. I know there is an option (I believe it is through the AHA) where you can complete the majority of the cert online (via videos); however, they will require that you complete the hands-on testing in person, which they provide several locations near you that offer it.
This site will direct you: http://www.onlineaha.org/
I agree with Karin. Not only should you check with your certifying agency to make sure that this would be accepted by them, but also with any employer or potential employer.
be aware that online CPR classes are usually not sufficient as proof for certifications and re-certifications.