/* ------------------------ My Meta Content Here SEO ------------------------ */


Main Menu

Monday, February 27, 2017

How to get odd/even value from array and display in table using Javascript

var dataArr = ["1","Maths","2","Science"];
Add a bare bones table to a div.
For each table row loop over the array in steps of 2 (i+=2). oddPositionVal is the first element in the step, evenPositionVal is the second element.
Build the row HTML and then append it to the table.

for (var i = 0, l = dataArr.length; i < l; i+=2) {
  var oddPositionVal = dataArr[i];
  var evenPositionVal = dataArr[i + 1];
  var rowhtml = ' ' + oddPositionVal + '' + evenPositionVal + ' ';


  1. Know About Online Passport Application Process Step by Step Process to apply Passport Online Application Form? Appointment Scheduling, click here to know more.
    online passport application form

  2. Stay connected with your friends and family with Idea's Mobile internet. Get best plans and experience superfast Internet across India.
    Idea 3G Prepaid Tariff Plans


My Blog List