/    Sign up×
Community /Pin to ProfileBookmark

Newbie – how to update a txt field with the current date with onchange dropdown field

Hey Peeps,

I want to create a javascript function where I have a dropdown list and onChage I want to update a txt field with the current date in the dd/mm/yyyy format. Could someone plz guide me on how I can do this?

Thanks,
Ket

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@kee2ka4authorAug 07.2009 — [CODE]
function setDate() {
document.form1.Accp_Date.value = now.format("dd/mm/yyyy");
}
[/CODE]


I wrote the above function but it doesn't work.. any guidance
Copy linkTweet thisAlerts:
@JMRKERAug 07.2009 — First off, I would change the name of your function as I believe it is a reserved function in JS

The following is un-tested because you did not include much of the other code:
<i>
</i>function set_Accp_Date() {
var now = new Date();
var dd = now.getDate(); // add test for values &lt; 10, for example 2 become 02 (if desired ???)
var mm = now.getMonth()+1; // similar test so 8 becomes 08 (if desired ???)
var yyyy = now.getFullYear();
var str = dd+'/'+mm+'/'+yyyy;
document.form1.Accp_Date.value = str;
}

Check out the numerous tutorials on Date() for JS (google?) or search this forum for other examples.

?
×

Success!

Help @kee2ka4 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...