?
Solved

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

Posted on 1997-11-11
1
Medium Priority
?
1,116 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
Holger101497 earned 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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.
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 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