Solved

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

Posted on 1997-11-11
1
1,090 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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

789 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