如何自动生成日期??? [英] How to autogenerate date ???
问题描述
〜朋友们,
我有一个文本框,其中要声明天数.
同时在另一个日期字段中,日期应自动生成.
在这里,新生成的日期基于另一个日期字段,并且其日期格式为:ex. 2010年1月16日.
例如:
文字框值:2
Date1:2010年1月16日
Date2:----//这是自动生成的....即Date1 + 2
如何在javascript的帮助下完成此操作?
请帮助我.
~Hi friends,
I have one textbox in which I am going to declare number of days.
At the same time in another date field a date should autogenerate.
Here the newly generated date is based upon one another date field and it has date format as : ex. 16 Jan 2010.
For example :
Text box value : 2
Date1 : 16 Jan 2010
Date2 :---- //This is auto generated.... i.e Date1 + 2
How can I do this with help of javascript?
Please help me.
推荐答案
设计
Days
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
Date 1
<asp:TextBox ID="TextBox2" runat="server" AutoPostBack="true" ontextchanged="TextBox2_TextChanged"></asp:TextBox>
<br />
Date 2 <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
编码
int days = int.Parse(TextBox1.Text);
DateTime dt = Convert.ToDateTime(TextBox2.Text);
TextBox3.Text = dt.AddDays(days).ToString();
Coding
int days = int.Parse(TextBox1.Text);
DateTime dt = Convert.ToDateTime(TextBox2.Text);
TextBox3.Text = dt.AddDays(days).ToString();
Text box value : 2
Date1 : 16 Jan 2010
Date2 :---- //This is auto generated.... i.e Date1 + 2
好吧,基于此:
1.将一个onchange事件挂接到textbox1
2.根据文本框中的数据输入,一旦完成,onchange将被触发
3.在您的onchange事件中,创建一个随机/今天的日期,并将其显示在另一个文本框2或日期字段中
4.同时,将两天或其他任何操作添加到textbox2日期,并在textbox3中显示这一新日期.
试试吧!
Well, based on this:
1. Hook a onchange event to textbox1
2. based on data entry in textbox, onchange would get fired once done
3. in your onchange event, create a random/todays date and show it in another textbox2 or in a date field
4. at the same time, add two days or any other manipulation to textbox2 date and show this new one in textbox3.
Try!
这篇关于如何自动生成日期???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!