473,397 Members | 2,068 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,397 software developers and data experts.

filling today's date in a form

Kun
i have a form which takes in inputs for a mysql query. one of the inputs
is 'date'. normally, a user has to manually enter a date, but i am
wondering if there is a way to create a button which would automatically
insert today's date in the date form field if the user chooses to use
today's date.
Apr 16 '06 #1
4 2762
Em Dom, 2006-04-16 Ã*s 19:22 -0400, Kun escreveu:
i have a form
Which kind of form? Which toolkit?
which takes in inputs for a mysql query. one of the inputs
is 'date'. normally, a user has to manually enter a date,
Enter the date in which kind of control?
but i am
wondering if there is a way to create a button which would automatically
insert today's date in the date form field if the user chooses to use
today's date.


Almost 100% sure that there is, but I can't tell you if or how if you
don't tell us how you are doing what you are doing.

--
Felipe.

Apr 16 '06 #2
Kun
Felipe Almeida Lessa wrote:
Em Dom, 2006-04-16 Ã*s 19:22 -0400, Kun escreveu:
i have a form


Which kind of form? Which toolkit?
which takes in inputs for a mysql query. one of the inputs
is 'date'. normally, a user has to manually enter a date,


Enter the date in which kind of control?
but i am
wondering if there is a way to create a button which would automatically
insert today's date in the date form field if the user chooses to use
today's date.


Almost 100% sure that there is, but I can't tell you if or how if you
don't tell us how you are doing what you are doing.

Form is an html form called by a python cgi file using fieldstorage.

Date as in '2006-04-16'... is that what you meant by control?
Apr 17 '06 #3
In article <e1***********@netnews.upenn.edu>, Kun <ne*******@gmail.com>
wrote:
... but i am
wondering if there is a way to create a button which would automatically
insert today's date in the date form field if the user chooses to use
today's date.


If you're going to have a button to do it, then the button might as well
invoke a JavaScript sequence to fill in the field. No sense bothering
the server with something this simple.
Apr 17 '06 #4
Lawrence D'Oliveiro wrote:
In article <e1***********@netnews.upenn.edu>, Kun <ne*******@gmail.com>
wrote:

... but i am
wondering if there is a way to create a button which would automatically
insert today's date in the date form field if the user chooses to use
today's date.

If you're going to have a button to do it, then the button might as well
invoke a JavaScript sequence to fill in the field. No sense bothering
the server with something this simple.


If JavaScript is enabled, the following example will do what
the OP wants:

<html>
<head>
<script type="text/javascript">
function getDate()
{
alert("getting date...");
var d = new Date();
var s = d.toLocaleString();
alert(s);
return s;
}
function setDate()
{
alert("Setting date");
document.getElementById("myDate").value = getDate();
}
</script>
</head>

<body>
<form name="form1">
Date: <input type="text" id="myDate" size="20" />
<br /><br />
<input type="button" value="Today's Date" onclick="setDate();">
</form>
</body>

</html>

However, if JS is not enabled (as I often surf, given how
requisite JS is for many attack vectors and popups...thank
goodness for the NoScript plugin for FireFox which allows me
to whitelist sites allowed to use JS), your only hope is to
round-trip the server where your CGI/mod_python/whatever
script is sitting generating the page. Or populate the
field by default (using 'value="1/2/03"' attribute on your
textbox) when creating the field and let the user change it
if needed. The ideal is to prepopulate the field to the
most frequently used value so that the user has as little
work to do as possible.

You'll find some great tools on JavaScript over at the
http://www.w3schools.com site where you can experiment with
their TryIt editor. That will at least allow you to tinker
with the JS. You haven't provided enough details regarding
your web-scripting environment (Django, CGI, TG, mod_python...)

-tkc

Apr 17 '06 #5

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

Similar topics

5
by: Janet Chapman | last post by:
I am creating a database for a video shop and in the loans table want there to be a field for date taken, with a default value of today. Trying to write =today() as in the help gives an error,...
1
by: Jimi Ffondu | last post by:
Hello all - apologies for putting such a banal request for help on a forum as distinguished as this, but I'm in trouble and didn't know where else to turn... It appears I've volunteered to...
2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
3
by: Omar Llanos | last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a button in Form2 that will fill up a textbox in Form1. What code would do that? I tried the simplest way: //from child...
1
by: TB | last post by:
Hi All: A kind soul provided by with the code for very nice calendar popup, which all in all works fine execpt for one thing: If I pick the current date (i.e. today's date) then the pop-up does...
0
by: TB | last post by:
Hi All: A kind soul provided by with the code for very nice calendar popup, which all in all works fine execpt for one thing: If I pick the current date (i.e. today's date) then the pop-up does...
7
by: joeyej | last post by:
How do I compare today's date with this string (in my inc file) so that I can set an alert if date choice i.e. May 15, 2006 not at least greater than two days from current date? <option...
5
by: M Skabialka | last post by:
I am creating my first Visual Studio project, an inventory database. I have created a form and used written directions to add data from a table to the form using table adapters, data sets, etc. ...
1
by: cptuser | last post by:
Hi, I have a date field on a form. The date in the date field has to be after today's date and not in the past. It also has to be within 30 days from today's date. So if today is 13/04/2007, then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.