单个数据库字段的两个输入字段 [英] Two input fields to a single database field

查看:71
本文介绍了单个数据库字段的两个输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我不知道这会叫什么,搜索上面的主题

是没用的。常见问题解答似乎也没有提供任何东西。

我继承的应用程序已经使用Javascript进行数据输入

验证所以我认为这也适合它。


这是我的情况:

我有一个表格(下方),日期输入可以过滤一个

数据库字段。我需要允许mM / dD / YYYY输入(已经

工作)和先前用户选择的天数。这应该是

过滤项目,这些项目的日期戳在今天的当前日期之前n天或者输入日期之前的天数。

的结束标准格式为日期mm / dd / yyyy。


Javascript可以帮我解决这个问题吗?这个叫什么?所以

也许我可以进一步搜索现有的帖子或网页。


提前致谢。


dlrider

表格代码:

< form name =" AdminFind" action =" index.cfm?action = adminfindlist"

method =" post">

在日期/之前修改的计划:

< input name =" plan_main_user_modify_date"类型= QUOT;文本" size = 10

maxlength = 10 value ="">

< input name =" find"类型= [提交"值= QUOT;查找与QUOT; onClick =" return

validateDate();" >

< / form>

Hello,
I don''t know what this would be called, and searches for the subject
above are not useful. FAQ did not seem to provide anything either.
My inherited application already uses Javascript for data input
validations so I thought this would be a good fit for it also.

Here''s my situation:
I have a form (below) with a date input to filter with on a single
database field. I need to allow mM/dD/YYYY input (which already
works) and number-of-days-prior -- user''s choice. This is supposed to
filter items that have a datestamp n number of days prior to today''s
current date OR prior to the date entered. The end criteria for
either is formatted as the date mm/dd/yyyy.

Can Javascript help me with this requirement? What is this called? So
maybe I can search further for existing posts or web pages.

Thanks in advance.

dlrider
form code:
<form name="AdminFind" action="index.cfm?action=adminfindlist"
method="post">
Plan modified on/before date:
<input name="plan_main_user_modify_date" type="text" size=10
maxlength=10 value="">
<input name="find" type="submit" value="Find" onClick="return
validateDate();" >
</form>

推荐答案

嘿dlrider,

看看这是否是你要找的。


< script language =" javascript">

function addtodate(date1,numberdays)

{

newdate = new Date(date1.getTime()+ numberdays *(1000 * 60 * 60 * 24));

返回newdate ;

}

mydate = addtodate(new Date(),3);

alert(mydate);

< / script>


这应该添加numberdays"到传递给函数的日期。你

可以修改它以减去它。你可能需要在mm / dd / yyyy上做一些

格式化来创建日期对象以传递给

函数。


Matt R.

周五,2007年9月7日12:46:59 -0700,dlrider< tw ****** @ gmail.com>

写道:
Hey dlrider,
See if this is what you are looking for.

<script language="javascript">
function addtodate(date1, numberdays)
{
newdate=new Date(date1.getTime()+numberdays*(1000*60*60*24));
return newdate;
}
mydate=addtodate(new Date(),3);
alert(mydate);
</script>

This should add "numberdays" to the date passed to the function. You
can modify it to subtract as well. You might have to do some
formatting on the mm/dd/yyyy to create the date object to pass to the
function.

Matt R.
On Fri, 07 Sep 2007 12:46:59 -0700, dlrider <tw******@gmail.com>
wrote:

>你好,
我不知道这会叫什么,搜索上面的主题是
没有用。常见问题解答似乎也没有提供任何东西。
我继承的应用程序已经使用Javascript进行数据输入验证,所以我认为这也非常适合它。

这里'我的情况是:
我有一个表格(下面),日期输入可以在单个数据库字段中过滤。我需要允许mM / dD / YYYY输入(已经有效)和先前用户选择的天数。这应该过滤在今天的当前日期之前或输入日期之前具有n天数的日期戳的项目。
的最终标准格式为日期mm / dd / yyyy。

Javascript可以帮我解决这个问题吗?这个叫什么?所以
也许我可以进一步搜索现有的帖子或网页。

提前致谢。

dlrider

表格代码:
< form name =" AdminFind" action =" index.cfm?action = adminfindlist"
method =" post">
在日期/之前修改的计划:
< input name =" plan_main_user_modify_date"类型= QUOT;文本" size = 10
maxlength = 10 value ="">
< input name =" find"类型= [提交"值= QUOT;查找与QUOT; onClick =" return
validateDate();" >
< / form>
>Hello,
I don''t know what this would be called, and searches for the subject
above are not useful. FAQ did not seem to provide anything either.
My inherited application already uses Javascript for data input
validations so I thought this would be a good fit for it also.

Here''s my situation:
I have a form (below) with a date input to filter with on a single
database field. I need to allow mM/dD/YYYY input (which already
works) and number-of-days-prior -- user''s choice. This is supposed to
filter items that have a datestamp n number of days prior to today''s
current date OR prior to the date entered. The end criteria for
either is formatted as the date mm/dd/yyyy.

Can Javascript help me with this requirement? What is this called? So
maybe I can search further for existing posts or web pages.

Thanks in advance.

dlrider
form code:
<form name="AdminFind" action="index.cfm?action=adminfindlist"
method="post">
Plan modified on/before date:
<input name="plan_main_user_modify_date" type="text" size=10
maxlength=10 value="">
<input name="find" type="submit" value="Find" onClick="return
validateDate();" >
</form>


在comp.lang.javascript消息中< 46 ********************* **@news.orange.f

r>,星期六,2007年9月8日01:44:50,ASM< st **************** *****@wanadoo.fr.in

validposted:
In comp.lang.javascript message <46***********************@news.orange.f
r>, Sat, 8 Sep 2007 01:44:50, ASM <st*********************@wanadoo.fr.in
validposted:

> user_day = user_day.split(''/'' );
>user_day = user_day.split(''/'');



可能OK

probably OK


> user_day = new Date(user_day [2],user_day [1] ,user_day [0]);
>user_day = new Date(user_day[2],user_day[1],user_day[0]);



这里通常需要A -1 ................ ^

A -1 is usually needed here ................^


> //自1970年以来用户所用的时间
>// time spent since 1970 for user''s day



否,这意味着1971-01年开始的86400秒-02本地。

你的意思是自1970-01-01 00:00:00 UTC以来的时间以毫秒为单位......

No, that would mean 86400 seconds for the start of 1971-01-02 local.
You mean "time in milliseconds since 1970-01-01 00:00:00 UTC ..."


> user_day = Date.parse(user_day);
>user_day = Date.parse(user_day);



最初,user_day是一个Date对象; Date.parse需要一个String,所以需要

隐式转换; Date.parse然后将转换回来(并且

会在公元一世纪的大部分时间里弄错)。

user_day = + user_day //将从Date对象转换为数字,

//可靠而快速。

如果一个人有两个类似地点的有效字符串日期,可能还有不同季节的b
和时间零件缺席,零或类似,

然后

DaysDifference = Math.round((新日期(DS2) - 新日期(DS1))/ 864e5)


-

(c)John Stockton,英国萨里。 ?@merlyn.demon.co.uk Turnpike v6.05 IE 6

news:comp.lang.javascript FAQ< URL:http://www.jibbering.com/faq/index.html> ;。

< URL:http://www.merlyn.demon.co.uk/js-index.htmjscr数学,日期,来源。

< URL :http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/& c,常见问题项目,链接。

Initially, user_day was a Date Object; Date.parse requires a String, so
implicit conversion is needed; Date.parse will then convert back (and
would get it wrong for most of the First Century AD).
user_day = +user_day // will convert from Date Object to Number,
// reliably and rapidly.
If one has two valid string dates for similar locations and possibly
dissimilar seasons, and the time parts are absent, zero, or similar,
then
DaysDifference = Math.round( ( new Date(DS2)-new Date(DS1) )/864e5 )

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.


在comp。 lang.javascript消息< 7dc3e394jrrq4ed5a4f54akaokivs04cce @ 4ax。

com>,星期五,2007年9月7日16:29:20,Matt Ratliff< ma *** @ safedataisp.net>

发布:
In comp.lang.javascript message <7dc3e394jrrq4ed5a4f54akaokivs04cce@4ax.
com>, Fri, 7 Sep 2007 16:29:20, Matt Ratliff <ma***@safedataisp.net>
posted:

newdate = new Date(date1.getTime()+ numberdays *(1000 * 60 * 60 * 24));
newdate=new Date(date1.getTime()+numberdays*(1000*60*60*24));



伪劣编码,但会通过简单的测试。好的,如果只在北京,阿克拉,夏威夷这样的地方使用。


-

(c)约翰斯托克顿,萨里,英国。 ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.

Web< URL:http://www.merlyn.demon.co.uk/- w。常见问题主题,链接,首字母缩略词

PAS EXE等:< URL:http://www.merlyn.demon.co.uk/programs/-见00index.htm

日期 - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm等

Shoddy coding, but will pass simple-minded testing. OK if used only in
places like Beijing, Accra, Hawaii.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.


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

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