Here's what comes to mind initially:
1. Bad AC adapter
2. The AC adapter connector is loose, either at the end of the cable or on the laptop itself.
3. Bad battery, or improper fit.
My wife had a ZE 4000 series HP lappy. We had to send it in twice for repairs to the soldered on connector on the mother board. (Where the AC adapter plugs into). It has a design/manufacturing flaw that can cause it to come loose and short, creating an intermittent charging situation. I've also had an AC adapter go bad, Perhaps you can find someone with a similar HP or Compaq laptop and try their adapter? If it cures your problem you can order a replacement. Beware - not just any adapter will work. Some seem identical but produce slightly different output. However, many of the HP's and Compaqs used the same adapterl
Good luck, CD