将textbox的值放在另一个文本框中 [英] Put value of textbox into another textbox

查看:121
本文介绍了将textbox的值放在另一个文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个开始日期,由用户通过jquery日期选择器放入一个文本框。

我还有一个结束日期文本框,我想填写开始日期值,当用户更改了开始日期的价值。

I have a start date which is put in a textbox by the user trough a jquery date picker.
I also have an end date textbox which I want to fill with the start date value when the user changed the value of the start date.

所以我在想一个JavaScript,而当一个文本框将输入值更改为结束日期文本框时,我不知道

So I was thinking of doing a JavaScript and than a when textbox has changed enter value into end date textbox but I don't know how this would be done.

谢谢你们的帮助,因为我是新的JavaScript。

Thank you guys for helping since I am new to JavaScript.

推荐答案

这是您所要求的工作代码。

Here is the working code for what you have asked.

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>jQuery UI Datepicker - Select a Date Range</title>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.9.1.js"></script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
        <script>
            $(function() {
                $("#fromdate").datepicker({
                    onSelect: function() {
                        $(this).change();
                    }
                });
                $("#fromdate").change(function (){
                    var val=$("#fromdate").val();
                    $("#todate").val(val);
                });
            });
        </script>
    </head>
    <body>
        <label for="from">From</label>
        <input type="text" id="fromdate" name="from">
        <label for="to">to</label>
        <input type="text" id="todate" name="to">


    </body>
</html>

并工作JSFiddle 这里

这篇关于将textbox的值放在另一个文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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