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?
@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 < 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.