Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

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

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;
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How are you calling your function?