最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery copy from Excel to multiple input fields - Stack Overflow

programmeradmin0浏览0评论

I have na excel sheet with the data:

English | Spanish | Italian | French

I'd like to be able to copy all these inputs and paste it to the form:

<input type="text" name="english">
<input type="text" name="spanish">
<input type="text" name="italian">
<input type="text" name="french">

so far when I copy all the data it will all paste into first input field. I'm asking this before I start coding as I'm not sure if it's even possible to do.

Any directions appreciated!

I have na excel sheet with the data:

English | Spanish | Italian | French

I'd like to be able to copy all these inputs and paste it to the form:

<input type="text" name="english">
<input type="text" name="spanish">
<input type="text" name="italian">
<input type="text" name="french">

so far when I copy all the data it will all paste into first input field. I'm asking this before I start coding as I'm not sure if it's even possible to do.

Any directions appreciated!

Share Improve this question asked Jun 13, 2014 at 15:28 GrasperGrasper 1,31312 silver badges27 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Upon your clarification, you can use jQuery to capture the paste action into anyone of those fields. Then simply parse and send it to the right input box.

HTML

<input type="text" name="english">
<input type="text" name="spanish">
<input type="text" name="italian">
<input type="text" name="french">

jQuery

$('input').bind('paste', null, function(e){
    $this = $(this);

    setTimeout(function(){
        var columns = $this.val().split(/\s+/);
        $this.val(' ');
        var i;

        for(i=0; i < columns.length; i++){
            var name = columns[i].toLowerCase();
            $('input[name="' + name + '"]').val(columns[i]);
        }
    }, 0);
});

Here's a demo fiddle to look at : http://jsfiddle/adjit/3N94L/3/

The clipboard is not going to allow this. You might want to look into a library like HandsOnTable which will parse the clipboard/excel data and run the paste into multiple inputs.

http://handsontable./

发布评论

评论列表(0)

  1. 暂无评论