0

I am editing a HTML file and there is one attribute application deadline. How can I set a default value to the application deadline to one year after today in the html code? Thanks for helping

Below is the original HTML code

 <div class="field" > Application Deadline: <input type="date" id="id_application_deadline" name="application_deadline"> </div>> 
1
  • use Java Script simply HTML won't do the work. HTML is just static representation of the data. Commented May 29, 2013 at 6:03

3 Answers 3

2

This is not possible without java script, Try this

<script language="javascript"> <!-- today = new Date(); document.write("", today.getDate(),"/",today.getMonth()+1,"/",today.getYear()); //--> </script> 
Sign up to request clarification or add additional context in comments.

Comments

1

Just set the desired date as value attribute:

<input type="date" id="id_application_deadline" name="application_deadline" value="2013-05-29"> 

If you're only using html, without javascript, there won't be a way to calculate the 1 year offset i think.

Comments

0

try this

<head> <script type="text/javascript"> function onload() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; var yyyy = today.getFullYear(); yyyy = parseInt(yyyy) + 1; today = dd+'-'+mm+'-'+yyyy; document.getElementById("id_application_deadline").value = today; } </script> </head> <body onload="onload()"> <div class="field" > Application Deadline: <input type="text" id="id_application_deadline" name="application_deadline"> </div> </body> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.