473,800 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="<javascr ipt command here">

Can anyone help?

Thanks in advance.

Cheers
Shaiboy_UK

Jul 23 '05 #1
9 2548
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="<javascr ipt command here">

<body onload="documen t.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="<javascr ipt command here">

<body onload="documen t.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="documen t.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.co m> wrote in message
news:qm******** ***********@twi ster.nyroc.rr.c om...
<body onload="documen t.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="documen t.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.co m> 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="<javascr ipt command here">

<body onload="documen t.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.toStrin g() 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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #7
"Mick White" <mw***********@ rochester.rr.co m> wrote in message
news:M_******** ************@tw ister.nyroc.rr. com...

<html>
<body onload="documen t.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.co m> wrote in message
news:M_******** ************@tw ister.nyroc.rr. com...
<html>
<body onload="documen t.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(do cument.forms[0]){date.value=th e.date;time.val ue=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.getMin utes()
}

</script>

Mick

Jul 23 '05 #9
"Mick White" <mw***********@ rochester.rr.co m> wrote in message
news:Oc******** **********@twis ter.nyroc.rr.co m...

<body
onload='with(do cument.forms[0]){date.value=th e.date;time.val ue=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.getMin utes()
}

</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
3736
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 my filed "date" in table "experience" is like this: Y-m-d (2002-07-23). My fied`date` is date, NOT NULL with no default entry My form read well the date data depending the id, (pe. 30.02.2003), but when I submit a new date, I receive as result...
2
10215
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 document.write(mmddyy)
21
1947
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" size="20"><br> 90 days from date</p> <p><input type="submit" value="Submit" name="B1"></p>
7
19634
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, Don Following running on client-side:
8
25390
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" size=3> Month: <input name="m1" alt="Month" size=3> Year: <input name="y1" alt="Year" size=5> (4 digits for year, e.g.
6
4851
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 selected and submitted. Thanks in advance for any help.
1
2025
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
6810
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 allows the employee to enter their UserID and select "Login" or "Logout" and then click a submit. When the submit button is clicked, I want the application to dum the NT Userename, UserID, status (Login or Logout) and a date/time stamp into an MS Access...
5
1836
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 Suppose I Have Saves Data Recordenrty Of Cash Recipt On 2/10/2007 And Its Id No. Is Auto Created 1 But Later On I Have Saved Data Record Of Cash Receipt Of 1/10/2007 Then Its Auto Id No. Should Be 1 And Ealier One Should Be Ajusted To No. 2...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.