We help IT Professionals succeed at work.

How to check or uncheck a checkbox using the id of the checkbox

brgdotnet
brgdotnet asked
on
72 Views
Last Modified: 2017-04-05
I have a java script function named showInfo(). Show info is passed the name/id of a specific check box control. Now I want to be able to check or uncheck the check box control based upon the control Id that I pass in to the Java script function? I have tried using getElementById but that isn't working. Does
anyone know how I can check the check box based upon the id of the check box control using Java Script?

function showInfo(idOfCheckBox)
{
    document.getElementById(idOfCheckBox).checked = true;
}
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
How are you calling your function?