When your chihuahua is about to eliminate pick him up and move him to the litter box. After he has eliminated be sure to praise him greatly. Repeat this continuously until he makes the association that you want him to go in the litter box.
Make sure he knows where the box is and that it is clean and easy for him to get to. When you see him having an accident pick him up, take him to the box, keep him there until he goes, give him lots of praise and a treat.
Encourage your dog to use the litterbox to go potty. When she poops outside the litterbox, put the poop in the litterbox so she understands that's where she is supposed to go. Whenever she potties in the box, praise her.
The best thing to do is if the dog look like its going to go to the bathroom put it in the litter. Or another alternative is to tie him down right next to there and they should eventually figure it out.