Java Questions
Java Questions

Reputation: 7963

How to get group of checkboxes values in javascript

i have a group of check boxes which has same name,it is as follows

one row has

      1.checkbox
      2.text box1
      3.text box2

i want to get the check box value which is selected as well the text boxes values which are in the row that the checkbox exist.

UPDATE :

S.No    Header Name     Size    Display Order
1        checkbox        25          1
2        checkbox        25          2
3        checkbox        25          3
4        checkbox        25          4

This is how my html page looks like, suppose if s.no 1 selected means i want to get the SIZE and DISPLAY ORDER values which are in text box.

this is the code i used but did not even goes in :

function customiseReport()
        {
           alert("customiseReport : ");
           var oParent = document.getElementById('headername');
           var aElements = oParent.getElementsByTagName('input');
           for (var i = 0; i < aElements.length; i++) {
              if (aElements[i].type == 'checkbox' && aElements[i].checked==true) {

              }
           }
        }

how to do this in javascript?

Please help.

Regards

Upvotes: 1

Views: 2976

Answers (1)

Khurshid
Khurshid

Reputation: 944

    <div id="checkbox_list">
        <input type="checkbox" class="checkboxes"/>
        <input type="checkbox" class="checkboxes"/>
        <input type="checkbox" class="checkboxes"/>
    </div>
    <button id="btn_clickme">Click me</button>
    <script type="text/javascript">
        $(function () {
            $('#btn_clickme').click(function () {
                alert('number of selected checkboxes: ' + $('.checkboxes:checked').size());
            });
        })
    </script>

Upvotes: 1

Related Questions