Skip to Content
avatar image
Former Member

How to Know Whether a check box is checked or not in a group

How to Know Whether a particular check box is checked or not in check box group on client side by using javascript

Thanks and Regards

Markandeya

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • May 31, 2004 at 09:58 AM

    Hi

    To check the value of a checkbox, you use the the following javascript

    if(document.getElementById("<id of the checkbox>").checked == true)

    If this doesn't work, it may be because you are using HTMLb and you will have to generate the ID field dynamically so that you capture the correct ID of the checkbox

    I hope this helps

    Add comment
    10|10000 characters needed characters exceeded

    • Hi

      I think the problem is that when you use the getParamIdForComponent you need to pass in the relevant component as opposed to the name of the component in quotes

      Try this code in your JSP page

      <%String checkBoxId = null;%>

      <hbj:checkbox

      id="myCheckbox"

      text="Click Here"

      tooltip="Click Here"

      disabled="false"

      checked="false"

      >

      <%checkBoxId = myContext.getParamIdForComponent(myCheckbox);%>

      </hbj:checkbox>

      Where myContext is the ID of the hbj:content.

      The javascript would be

      document.getElementById('<%=checkBoxId%>').checked;

      I hope this helps

      D