Lucky Draw

by akshatha suchethan

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="http://igniteui.com/js/modernizr.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/infragistics.core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/infragistics.lob.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.ext_core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.ext_collections.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.ext_text.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.ext_io.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.ext_ui.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.documents.core_core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/modules/infragistics.ext_collectionsextended.js"></script>
<script...

CSS

#sampleContainer ol {
  padding: 0px 0px 0px 15px;
  margin: 0;
}

#sampleContainer input {
  margin: 10px 0;
}

#result {
  display: none;
  color: red;
}

JavaScript

var array = [];
$(function() {
$('#btnSubmit').click(function (e) {
 alert(array.splice(Math.floor(Math.random()*array.length), 1));
  console.log(array);

});
  $("#input").on("change", function() {
  
    var excelFile,
      fileReader = new FileReader();

    $("#result").hide();

    fileReader.onload = function(e) {
      var buffer = new Uint8Array(fileReader.result);

      $.ig.excel.Workbook.load(buffer, function(workbook) {
        var column, row, newRow, cellValue, columnIndex, i,
          worksheet = workbook.worksheets(0),
          columnsNumber = 0,
          gridColumns = [],
          data = [],
          worksheetRowsCount;

        // Both the columns and rows in the worksheet are lazily created and because of this most of the time worksheet.columns().count() will return 0
        // So to get the number of columns we read the values in the first row and count. When value is null we stop counting columns:
        while (worksheet.rows(0).getCellValue(columnsNumber)) {
          columnsNumber++;
        }

        // Iterating through cells in first row and use the cell text as key and header text for the grid columns
        for (columnIndex = 0; columnIndex < columnsNumber; columnIndex++) {
          column = worksheet.rows(0).getCellText(columnIndex);
          gridColumns.push({
            headerText: column,
            key: column
          });
        }

        // We start iterating from 1, because we already read the first row to build the gridColumns array above
        // We use each cell value and add it to json array, which will be used as dataSource for the grid
        for (i = 1, worksheetRowsCount = worksheet.rows().count(); i < worksheetRowsCount; i++) {
          newRow = {};
          row = worksheet.rows(i);

          for (columnIndex = 0; columnIndex < columnsNumber; columnIndex++) {
            cellValue = row.getCellText(columnIndex);
            newRow[gridColumns[columnIndex].key] = cellValue;
           ...