javascript - How to convert my Array of data to key & value pair -


i have array this.

my array= partnernumber,1044,firstname,rob,rank,302 

i represented key , value pair

[1]partner number - 1044 [2]first name - rob [3] rank -302 

i need post array data , form query on server side control.

thanks in advance

in modern web browsers, can use useful array.foreach function:

var array = ["partnernumber",1044,"firstname","rob","rank",302];  var dictionary = {};  array.foreach(function(item, index) {     if(index % 2 === 0) {        dictionary[item] = array[index + 1];     } });  document.write("partner number:" + dictionary.partnernumber); 

try on jsfiddle:


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -