473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Putting date and time in input feild of form?!?!

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

Jul 23 '05 #1
9 2515
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
Jul 23 '05 #2
Lee
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.

Jul 23 '05 #3
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
Jul 23 '05 #4
"Mick White" <mw***********@rochester.rr.com> wrote in message
news:qm*******************@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
Jul 23 '05 #5
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
Jul 23 '05 #6
JRS: In article <qm*******************@twister.nyroc.rr.com>, dated
Fri, 14 Jan 2005 14:07:18, seen in news:comp.lang.javascript, Mick White
<mw***********@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.
Jul 23 '05 #7
"Mick White" <mw***********@rochester.rr.com> wrote in message
news:M_********************@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

Jul 23 '05 #8
Shaiboy_UK wrote:
"Mick White" <mw***********@rochester.rr.com> wrote in message
news:M_********************@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">


<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

Jul 23 '05 #9
"Mick White" <mw***********@rochester.rr.com> wrote in message
news:Oc******************@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
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
2
by: Scott Knapp | last post by:
Good Day - I have a form which sets the current date, as follows: <script type="text/javascript"> xx=new Date() dd=xx.getDate() mm=xx.getMonth()+1 yy=xx.getYear() mmddyy=mm+"/"+dd+"/"+yy...
21
by: Samir | last post by:
Say I put a date and time for like this: Jun-15-04 21:52:06 Here is the form I am using: <form> <p><input type="text" name="T1" size="20"><br> date</p> <p><input type="text" name="T2"...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
8
by: dlx_son | last post by:
Here is the code so far <form name="thisform"> <h3>Enter time to add to or subtract from:</h3> (If not entered, current time will be used)<br> Day: <input name="d1" alt="Day of month"...
6
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is...
1
by: nagamalli26 | last post by:
hai iam new php. i am creating admin side. i wrote this, phpcode: <?php //include_once("config.php"); $con=mysql_connect("localhost","root",""); mysql_select_db("happysalary"); ?>
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
5
by: jaemalegaon | last post by:
Hi , This Is Adarsh Jain Form Malegaon , A Remote Area In Dist Of Nashik, Maharastra(india), Wants Help In Arraning Data Record Of A Table According To Date Feild Of Data Record Of Same Table, I.e...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.