jQuery从Excel复制到多个输入字段 [英] jQuery copy from Excel to multiple input fields

查看:112
本文介绍了jQuery从Excel复制到多个输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  English |西班牙语|意大利语|法语

我希望能够复制所有这些输入并粘贴到以下格式: / p>

 < input type =textname =english> 
< input type =textname =spanish>
< input type =textname =italian>
< input type =textname =french>到目前为止,当我将所有数据全部粘贴到第一个输入字段时,


我在开始编码之前要问这个问题,因为我不确定是否可以做到这一点。



任何方向感谢!

解决方案

根据您的澄清,您可以使用jQuery将粘贴操作捕获到任何这些字段中。然后简单解析并发送到正确的输入框。



HTML



 < input type =textname =english> 
< input type =textname =spanish>
< input type =textname =italian>
< input type =textname =french>



jQuery



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

setTimeout(function()
var columns = $ this.val()。split(/ \s + /);
$ this.val('');
var i;
$ b $对于(i = 0; i< columns.length; i ++){b $ b var name = columns [i] .toLowerCase();
$('input [name ='+ name + ]')。val(columns [i]);
}
},0);
});

这是一个演示小提琴,看看: http://jsfiddle.net/adjit/3N94L/3/


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!

解决方案

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/

这篇关于jQuery从Excel复制到多个输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆