Hi all,
Hopefully something simple here.
I have written a form that takes data from a text box and updates it into an
Access database. However, I want to also pass the local user date and time
using date() and time() JavaScript commands, but can't find the right syntax
to put them in the input command, example:
<input name=date value="<javascript command here">
Can anyone help?
Thanks in advance.
Cheers
Shaiboy_UK
|
|
0
|
|
|
|
Reply
|
Shaiboy_UK
|
1/14/2005 8:42:40 AM |
|
Shaiboy_UK wrote:
> Hi all,
>
> Hopefully something simple here.
>
> I have written a form that takes data from a text box and updates it into an
> Access database. However, I want to also pass the local user date and time
> using date() and time() JavaScript commands, but can't find the right syntax
> to put them in the input command, example:
> <input name=date value="<javascript command here">
>
<body onload="document.forms[0].date.value=new Date()">
....
<input name=date type="text">
Mick
|
|
0
|
|
|
|
Reply
|
Mick
|
1/14/2005 2:07:18 PM
|
|
Mick White said:
>
>Shaiboy_UK wrote:
>
>> Hi all,
>>
>> Hopefully something simple here.
>>
>> I have written a form that takes data from a text box and updates it into an
>> Access database. However, I want to also pass the local user date and time
>> using date() and time() JavaScript commands, but can't find the right syntax
>> to put them in the input command, example:
>> <input name=date value="<javascript command here">
>>
><body onload="document.forms[0].date.value=new Date()">
>...
><input name=date type="text">
But realize that this is the date and time as set on the visitor's
desktop, which may have no relationship to reality. In fact, the
time reported by the browser may not even match what the visitor sees
on their desktop.
|
|
0
|
|
|
|
Reply
|
Lee
|
1/14/2005 3:41:38 PM
|
|
Lee wrote:
> Mick White said:
>>>
>><body onload="document.forms[0].date.value=new Date()">
>>...
>><input name=date type="text">
>
>
> But realize that this is the date and time as set on the visitor's
> desktop, which may have no relationship to reality. In fact, the
> time reported by the browser may not even match what the visitor sees
> on their desktop.
>
True...
Mick
|
|
0
|
|
|
|
Reply
|
Mick
|
1/14/2005 5:42:26 PM
|
|
"Mick White" <mwhite13BOGUS@rochester.rr.com> wrote in message
news:qmQFd.137213$Uf.56745@twister.nyroc.rr.com...
> <body onload="document.forms[0].date.value=new Date()">
> ...
> <input name=date type="text">
>
> Mick
Hi Mick,
Tried, but doesn't seem to work. Put it on my testscripts folder at:
http://www.theukserver.net/testscript/readdate.html
have a look, and let me know.
Thanks in advance.
Cheers
Shaiboy_UK
|
|
0
|
|
|
|
Reply
|
Shaiboy_UK
|
1/14/2005 5:51:52 PM
|
|
Shaiboy_UK wrote:
>
> Tried, but doesn't seem to work. Put it on my testscripts folder at:
> http://www.theukserver.net/testscript/readdate.html
> have a look, and let me know.
<html>
<body onload="document.forms[0].date.value=new Date()">
<form>
<input type="text" name="date">
</form>
</html>
It's preferable to use "new Date()", rather than "Date()" as you have.
Mick
|
|
0
|
|
|
|
Reply
|
Mick
|
1/14/2005 7:23:24 PM
|
|
JRS: In article <qmQFd.137213$Uf.56745@twister.nyroc.rr.com>, dated
Fri, 14 Jan 2005 14:07:18, seen in news:comp.lang.javascript, Mick White
<mwhite13BOGUS@rochester.rr.com> posted :
>Shaiboy_UK wrote:
>> I have written a form that takes data from a text box and updates it into an
>> Access database. However, I want to also pass the local user date and time
>> using date() and time() JavaScript commands, but can't find the right syntax
Could be because neither date() nor time() exists.
>> to put them in the input command, example:
>> <input name=date value="<javascript command here">
>>
><body onload="document.forms[0].date.value=new Date()">
>...
><input name=date type="text">
IMHO, while "date" is a perfectly legal name, it's not an ideal choice,
since it is too near "Date" to be typo-proof. "Today" would seem
better.
The date that goes into the Access database must be in a format that
Access considers appropriate; it's dangerous to assume that new Date(),
in any locality, will give a form that Access will accept specifically;
IIRC, the format of DateObj.toString() is not actually defined.
Note : the OP is in UK, his application may be UK or wider. Sometimes,
though localised to UK, browsers give FFF dates; sometimes, though in
UK, browsers are not localised to UK (in our Public Library, last time I
looked, localisation was US; but most users might have preferred KR).
I don't know what Access can accept, with/without localisation; give the
date/time in ISO 8601:2004 if possible - YYYY-MM-DD hh:mm:ss; or
YYYY/MM/DD hh:mm:ss. Do not rely, except maybe on an intranet, on any
formats offered by javascript; build what you want in a localisation-
proof manner, unless you are satisfied that both products will always
localise compatibly.
See below.
--
� John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 �
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
|
|
0
|
|
|
|
Reply
|
Dr
|
1/14/2005 9:14:24 PM
|
|
"Mick White" <mwhite13BOGUS@rochester.rr.com> wrote in message
news:M_UFd.151741$AL5.84331@twister.nyroc.rr.com...
>
> <html>
> <body onload="document.forms[0].date.value=new Date()">
> <form>
> <input type="text" name="date">
> </form>
> </html>
>
> It's preferable to use "new Date()", rather than "Date()" as you have.
> Mick
Hi Mick,
Any way I could get the date and time in two boxes in the format of:
DD/MM/YY and HH:MM ? like in this format??
<input type="text" name="date">
<input type="text" name="time">
Thanks for this.
Cheers
Shaiboy_UK
|
|
0
|
|
|
|
Reply
|
Shaiboy_UK
|
1/18/2005 8:41:17 AM
|
|
"Mick White" <mwhite13BOGUS@rochester.rr.com> wrote in message
news:OcbHd.146730$Uf.5855@twister.nyroc.rr.com...
>
> <body
> onload='with(document.forms[0]){date.value=the.date;time.value=the.time}'>
> <form>
> <input type="text" name="date">
> <input type="text" name="time">
> </form>
>
>
> <script type="text/JavaScript">
> d=new Date()
> the= {
> date:d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear(),
> time:d.getHours()+":"+d.getMinutes()
> }
>
> </script>
>
> Mick
>
>
Thanks Mike,
Cheers
Shaiboy_UK
|
|
0
|
|
|
|
Reply
|
Shaiboy_UK
|
1/18/2005 11:31:34 PM
|
|
|
8 Replies
256 Views
(page loaded in 0.181 seconds)
Similiar Articles: Putting date and time in input feild of form?!?! - comp.lang ...Hi all, Hopefully something simple here. I have written a form that takes data from a text box and updates it into an Access database. However, I w... Put a date in a mysql - comp.lang.java.guiPutting date and time in input feild of form?!?! - comp.lang ... If the goal is to put the date/time of file creation in the ... set (or a large file of ... Insert a string into the text of textarea. Caret? IE question ...Putting date and time in input feild of form?!?! - comp.lang ..... form that takes data from a text box and updates it into an ... in the form is a serial number ... Intranet Links - comp.lang.javascriptPutting date and time in input feild of form?!?! - comp.lang ... Do not rely, except maybe on an intranet, on any formats offered by javascript; build ... <URL:http://www ... Control charcters in form input field - comp.lang.javascript ...Putting date and time in input feild of form?!?! - comp.lang ... Control charcters in form input field - comp.lang.javascript ... The exact same input is put into the form ... Converting a datetime field to a date without using datepart() in ...... please as I need to convert a datetime field to a date but ... The input and put functions are not passed to the RDBMS. ... Date/time to date format in PROC SQL - comp.soft ... AWK question - split string into variables - comp.unix.shell ...... not start until after begin time begin time is in the form of ... approach this to pass in the target date/time plus ... digit:]]+$/) { printf "Input field %d (%s ... wrong week number in date format - comp.databases.ms-access ...Putting date and time in input feild of form?!?! - comp.lang ... wrong week number in date format - comp.databases.ms-access ..... within the form where I have date with ... read and merge lots of txt files, macro? - comp.soft-sys.sas ...Putting date and time in input feild of form?!?! - comp.lang ... read and merge lots of txt files, macro? - comp.soft-sys.sas ..... VARIABLE FIELD DEC ... if _n_=3D1 then ... ODBC Database Insert 'DateTime' - comp.soft-sys.matlabI have tried putting the value for the date in many different forms (as datenum, as string of various mm ... If this helps, the exact database field is a Date/Time field in ... Putting date and time in input feild of form?!?! - comp.lang ...Hi all, Hopefully something simple here. I have written a form that takes data from a text box and updates it into an Access database. However, I w... Putting date and time in input feild of form?!?! - JavaScript ...Putting date and time in input feild of form?!?!. JavaScript / Ajax / DHTML Forums on Bytes. 7/24/2012 11:39:28 AM
|