kad1r
8/1/2013 - 7:59 AM

Get input hidden types and checkboxes ...

Get input hidden types and checkboxes ...

function hiddenByName() {
  // consider you have a div or table which name is dvHiddenValues
  // consider you have a hidden inputs which name is myHdValues
  var arrList = new Array();
  // that gives you the list of hidden inputs which name is myHdValues
  var hiddenList = document.getElementById('dvHiddenValues').document.getElementsByName('myHdValues');
  for (var i = 0; i < hiddenList.length; i++) {
      arrList.push(hiddenList[i].value);
  }
}

// this function gives you the checkbox list that you checked
function findCheckboxes() {
    var checkedList = new Array();
    // consider you have a div or table which name is dvMyDiv
    var inputs = document.getElementById('dvMyDiv').document.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].type == 'checkbox') {
            if (inputs[i].checked) {
                checkedList.push(inputs[i].value);
            }
        }
    }
}

// this function gives you the checkbox list which has spesific id that you checked
function findCheckboxes() {
    var checkedList = new Array();
    // consider you have a div or table which name is dvMyDiv
    var inputs = document.getElementById('dvMyDiv').document.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; i++) {
      // consider checkbox id's stars with chkbx, ex: <input type="checkbox" id="chkbx_1" value="5" />
        if (inputs[i].type == 'checkbox' && inputs[i].id.indexOf('chkbx') == 0) {
            if (inputs[i].checked) {
                checkedList.push(inputs[i].value);
            }
        }
    }
}