Solved

How to put today's date in a <input> tag

Posted on 1997-11-11
1
1,088 Views
Last Modified: 2013-12-25
I have a form and I need to include the
<input type="date" value="***">
*** as being today's date . It should automatically capture today's date and replace the *** .

Anyone know how to accomplish this?
Can this be done with javascript ? If so can anyone give me the code for it?

Thanks for any help !
0
Comment
Question by:anusha
1 Comment
 
LVL 6

Accepted Solution

by:
Holger101497 earned 100 total points
ID: 1855507
In Netscape Navigator, there is a very nice way of including JavaScript-values in HTML-code. The shortest form of that would look like this:
<input type=text name=dateinput value="&{new Date()};">
The string will always be in the format used on the local computer. If you don't like that format, you will have to assign the value "the hard way" ;-)

  <form name=form1>
    <input name=dateinput type=text value="&{(new Date())};">
  </form>
  <script>
     D = new Date();
     document.form1.dateinput.value=D.getMonth()+"-"+D.getDate()+"-"+D.getYear();
  </script>

If you have more values to initialize, it might be better to place all these initializations into a separate function and call it in the "onload" handler of the body:
<BODY .... onload="Initialize()">

Good luck! Let me nkow if you have any questions...

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Retrieve response header - authorization bearer token 34 111
ajaxSubmit is giving me an error 1 34
Two wordpress questions 3 43
Wordpress plugins not working in html 3 19
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now