How To Paste From Excel To Multiple Inputs Using jQuery

How To Paste From Excel To Multiple Inputs Using jQuery

In order to be able to paste from excel to multiple inputs, you will have to split the whole string in an array and then just change the value of every input. Let me show the code you need to add:

jQuery('.paste-me').on('paste', function(e){

    var data1 = e.originalEvent.clipboardData.items[0];
    if(data1.kind == 'string' && data1.type == 'text/plain'){
      e.stopPropagation();
      data1.getAsString(function(s){
        s = s.split('\t');
        if(s.length > 0){
        	jQuery('.paste-me').each(function(i,item){
        		jQuery(item).val(s[i]);
	        });
        
        }
      });
    }
  });

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x