Friday, February 2, 2018

Java Script Function To Return Selected Checkbox Value

Get the selected checkbox value from the group of checkbox list in Javascript. I wrote one function to return the selected checkbox value in Javascript.

<script type='text/javascript>

// Java Script function to return the selected checkbox value
function Checkbox_Selection_Value_From_Group (){
  fileid= $(\"input[name='filegroup[]']:checked\").map(function() {
            return this.value;
          }).get();
    if(fileid==''){
        alert('Select Minimum One Check Box');
        return false;
    }else{
  // You Will get comma separated value 
        // 1,2
       return 'id='+fileid;
    }
}
</script>

<input type="checkbox" id="filegroup" name="filegroup[]" value="1">
<input type="checkbox" id="filegroup" name="filegroup[]" value="2">
<input type="checkbox" id="filegroup" name="filegroup[]" value="3">
<input type="checkbox" id="filegroup" name="filegroup[]" value="4">

Share:

0 comments:

Post a Comment

Popular Posts

Blog Archive