javascript - how can i add keys in val array in it -


function asign(id){ return document.getelementbyid(id) ; }   function values(id){ return document.getelementbyid(id).value ; }  asign('btn').addeventlistener('click',validate,false) ;  function validate(){ var ids = ['name1','name2','pass'] ; var val = [];  for(var = 0 ; i<ids.length;i++){          val.push(values(ids[i])) ;    }  }  

i want in val array include keys in array val[text]='name1' value , val[password]= 'pass' value how can done .because in next create different groups text , password validate in different types

function asign(id){ return document.getelementbyid(id) ; }   function values(id){ return document.getelementbyid(id).value ; }  asign('btn').addeventlistener('click',validate,false) ;  function validate(){ var ids = ['name1','name2','pass'] ; var val = {};  for(var = 0 ; i<ids.length;i++){      val.value = values(ids[i]); }  }  

you can add additional params dictionary create..

    val.password = password; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -