将多个输入值克隆到一个输入字段中 [英] Clone multiple input values into one input field

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

问题描述

我正在尝试将多个字段的输入数据复制到一个大字段中,以作为生日.

I'm trying to copy the input data of multiple fields into one big one, for date of birth.

日值+月值+年值=日值/月值/年值一起进入另一个字段.我在每个字段中都做了变量,然后尝试将它们添加到完整"输入字段中,但这是行不通的.我在做什么错了?

day value + month value + year value = day value/month value/year value into one other field all together. I made variables of each field and then try to add them in the 'full' input field, but this doesn't work. What am I doing wrong?

演示: http://jsfiddle.net/J2PHq/

$(function(){
    $('.copy').on('keyup blur', function(){
         $('.full').val(day + '/' + week + '/' + year);

        day = $(".day").val();
        week = $(".week").val();
        year = $(".year").val();
     }).blur();
});

推荐答案

您需要先声明变量,然后才能在.full字段中输入变量.

You need to declare the variables before you enter them in the .full field.

正在工作的小提琴:此处

$(function(){
    $('.copy').on('keyup blur', function(){        
        var day = $(".day").val();
        var week = $(".week").val();
        var year = $(".year").val(); 

        $('.full').val(day + '.' + week + '.' + year);

     }).blur();
});

这篇关于将多个输入值克隆到一个输入字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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