Any erection dysfunction can be due to semi or complete loss of erection. Lifestyle choices like excessive smoking, being overweight and avoiding exercise are possible causes. In such cases quitting smoking, losing excessive weight, and increasing physical activity may help some men regain sexual function. Other serious causes are neurogenic disorder (spinal cord and brain injuries), certain drugs like anti-depressants or nicotine cavernosal disorders, ageing, kidney failure, smoking, and psychological causes. Several laboratory tests can help to confirm diagnosis.
Tests for systemic diseases include blood counts, urinalysis, lipid profile, and measurements of creatinine, liver enzymes, and free testosterone in the blood. It can be treated by drugs taken orally, injected, or as penile suppositories after consulting a doctor. Exercise, particularly aerobic exercise is very effective. When pharmacological methods fail; a purpose-designed external vacuum pump can be used to attain erection. Psychotherapy and behaviour modifications will be of great help for you.
I hope it helps. Take care and regards.