jQuery copy from Excel to multiple input fields

前端 未结 2 455
清歌不尽
清歌不尽 2021-01-16 12:43

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

相关标签:
2条回答
  • 2021-01-16 12:54

    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.com/

    0 讨论(0)
  • 2021-01-16 12:58

    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.net/adjit/3N94L/3/

    0 讨论(0)
提交回复
热议问题