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>>
Mona
  • 1,425
  • 6
  • 21
  • 31
  • use Java Script simply HTML won't do the work. HTML is just static representation of the data. – Mantra May 29 '13 at 06:03

3 Answers3

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>
Roy Sonasish
  • 4,571
  • 20
  • 31
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.

Imperative
  • 3,138
  • 2
  • 25
  • 40
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>
Vijay
  • 8,131
  • 11
  • 43
  • 69